Forecast tomorrow’s orders
Your store already records how many orders it gets each day. Spavik reads that history and forecasts tomorrow’s total, so you can plan stock and staffing ahead.
- Returns
- Tomorrow’s number of orders
- Language
- Python
In your app
Tomorrow
orders tomorrow
Show tomorrow’s order forecast.
The data you need
One row per day, in date order. Spavik reads that history to forecast the next value.
Daily order totals from your store.
| Column | Role | Meaning |
|---|---|---|
date | Date | One row per completed day |
orders | Predicted | Orders received that day |
The code
A complete, commented script. Set SPAVIK_API_KEY in your server environment, never in browser code.
from spavik import Spavik
# Set SPAVIK_API_KEY in your server environment.
spavik = Spavik()
# daily_orders.csv: date, orders.
# One row per completed day, in chronological order.
history = "daily_orders.csv"
# Check forecasts against past days before using them.
report = spavik.backtest(
history,
target="orders",
horizon=1,
timestamp="date",
)
print("Backtest:", report["assessment"]["message"])
# A period is one day: horizon=1 forecasts tomorrow.
forecast = spavik.forecast(
history,
target="orders",
horizon=1,
timestamp="date",
)
# Show tomorrow's forecast to the store team.
orders = forecast.points[0]["orders_prediction"]
print(f"Orders tomorrow: {orders:,.0f}")
How it works
- 1
Check past days
backtest()replays your history for free and shows how forecasts would have done. - 2
Forecast the next day
forecast()reads your history and returns tomorrow’s value. No model to keep. - 3
Show it in your app
Display the value where your team plans. One credit per call with
horizon=1.
Questions
How much history do I need?
One row per day, sorted by date, with at least as many points as the periods you ask for, and preferably several times more. backtest() replays your history for free to show how forecasts would have done.
What does it cost?
backtest() is free. forecast() keeps no model and costs the requested horizon per call, all series included: forecasting tomorrow with horizon=1 costs one credit.