Forecasting
A forecast that cannot beat "repeat last period" is noise. Baseline first, fancy second. The naive forecast is free, instant, and the bar every model must clear — if your AutoARIMA loses to last-quarter-repeated, ship the repeat and say so.
You are not done when a model produces a number. You are done when you can defend the number: which method, why that method for this data, how it scored against the naive baseline in a backtest, and the interval around the point. A point estimate with no error band is a guess wearing a lab coat.
The deliverable contract
Every forecast you ship is a reproducible artifact, not a number pasted in chat:
- A script that reads the history and regenerates the forecast (no manual steps).
- A CSV/Parquet with columns
ds, forecast, lo, hi— timestamp, point, interval bounds. - A one-paragraph accuracy readout: WAPE + bias from a rolling-origin backtest, and MASE vs the naive baseline (MASE < 1.0 = you beat naive; ≥ 1.0 = ship the naive forecast instead).
If you cannot produce all three, you have not forecast — you have guessed. scripts/verify.sh checks the artifact has these columns, the right row count, and an accuracy line.
The loop
Run these in order. Skipping step 3 is the most common failure.
- Frame it. Pin down the horizon
h(how many periods forward), the granularity (daily / weekly / monthly), and exactly what is being predicted (units? revenue? per-SKU or aggregate?). Forecast at the level you will act on — if you reorder per SKU, forecast per SKU, then sanity-check against the aggregate. - Establish the series. Regular timestamps, one row per period, gaps filled explicitly (a missing month is not zero unless it truly is). Flag promotions, stockouts, and outliers — they distort the signal. If the input is dirty (dupes, missing rows, mixed units), stop and hand off to
data-cleaningbefore modeling. Garbage history, garbage forecast. - Build the naive + seasonal-naive baseline. This is the bar. Naive = repeat last value. Seasonal-naive = repeat the value from one season ago (e.g. last December for this December). Compute its backtest error now — every fancier method must beat it or lose.
- Pick the method by data shape (table below). Do not reach for ARIMA on instinct.
- Backtest with rolling-origin cross-validation. Never a single holdout. Compute WAPE + bias + MASE vs the naive baseline across multiple cutoffs.
- Report. Point + interval, the one-line method rationale, the accuracy readout. Then hand off downstream (
inventory,financial-model).
Method selection
Match the method to the shape of the history, not to what sounds sophisticated. statsforecast (Nixtla, v2.0.3) provides all of these with built-in intervals.
| Data shape | Method | statsforecast call | Why |
|---|---|---|---|
| Flat, no trend or season | Moving average or SES | SimpleExponentialSmoothingOptimized() / 3-period MA | Nothing to model; a mean is honest. |
| Trend, with or without season | ETS | AutoETS(season_length=m) | ETS captures level+trend+season cleanly, no manual order. |
| Strong known seasonality / autocorrelation | ARIMA | AutoARIMA(season_length=m) | Handles autocorrelated errors; ~20x faster than pmdarima. |
| Many zeros (intermittent / lumpy demand) | Croston / SBA | CrostonOptimized() | SES is provably wrong on sporadic demand (Croston 1972); SBA debiases it. |
| < 2 full seasonal cycles of history | SeasonalNaive only | SeasonalNaive(season_length=m) | Too little data to fit a model. Do not fit one. Full stop. |
When in doubt between two, fit both plus the baseline in one StatsForecast run and let the backtest decide. Theta (AutoTheta) is a strong, cheap default that often wins on monthly business series.
Accuracy and honesty
The metrics are not decoration — they decide what you ship.
- WAPE, not MAPE. MAPE divides by the actual, so it explodes and misleads whenever actuals approach zero (constant in SKU and intermittent data). WAPE = total absolute error / total actual volume — volume-weighted and stable. It is the default magnitude metric.
- Pair WAPE with bias. WAPE is how big the error is; bias is the direction — whether you systematically over- or under-forecast. A 10% WAPE with +9% bias means you are almost always forecasting high, an actionable problem quite different from random error.
- MASE < 1.0 is the pass/fail line. MASE is scale-free: your error over the naive forecast's error. Below 1.0 you beat naive; at or above it, ship the naive forecast instead. The single most important number in the readout.
- Rolling-origin, never a single holdout. Time-series CV repeats the train/test split across multiple cutoffs (expanding window), a far more reliable estimate than one lucky/unlucky split. Use
cross_validation(h=…, n_windows=…). - Always emit an interval. A point forecast cannot express uncertainty, and point metrics cannot evaluate a distribution. Report
level=[80]or[95]. The interval is half the deliverable, not optional polish.
Formulas (WAPE, MASE, bias, pinball, coverage), rolling-origin mechanics, and how to read a backtest table are in