Manufacturing demand forecasting — the M5 winning method, end to end.
A three-tier system (engine · backend · dashboard) that turns raw daily sales into a 28-day demand forecast and a production recommendation for every SKU — built on the M5 competition 1st-place recipe. This page explains how it works; open Forecasts for live results.
1 · How the system works — pipeline
Ingest data
Daily demand history per item×store, plus price, SNAP, calendar events and product hierarchy.
Feature engineering
Lags ≥ horizon, rolling mean/std (7·14·30·60), price momentum, calendar, hierarchy codes, target mean-encoding. All shift-safe (no leakage).
Train — LightGBM (Tweedie)
A global gradient-boosted model + two quantile models, direct multi-step (no recursion). The M5 1st-place recipe.
Forecast
28-day daily forecast per SKU with a P10 / P50 / P90 prediction band.
Recommend (newsvendor)
Recommended production qty = forecast demand + safety stock (z·σ from the band), capped by capacity / MOQ / batch.
2 · Inputs & outputs
- Demand history
- Daily units sold per item × store (the target series).
- Price
- Selling price over time + normalized price and price momentum.
- Promotions / SNAP
- SNAP food-stamp days and promo signals — demand drivers.
- Calendar & events
- Holidays, sporting/cultural events, day-of-week, month.
- Product hierarchy
- Item, department, category, store, state (encoded).
- Demand forecast
- 28-day daily forecast per SKU, with a P10 / P50 / P90 band.
- Production recommendation
- Recommended quantity = forecast + safety stock, clamped by capacity / MOQ / batch.
- Safety stock
- z·σ buffer derived from the P10–P90 spread at a 95% service level.
- Accuracy scorecard
- Out-of-sample WRMSSE / WAPE from a rolling-origin backtest.
3 · The AI method — technical
- Granularity
- Daily — no weekly aggregation, so SNAP/price/event effects survive.
- Model
- Global LightGBM, objective = Tweedie (variance power 1.1) — best for sparse, spiky demand.
- Multi-step
- Direct (non-recursive): every horizon day is predicted from observed lags ≥ horizon — no error compounding.
- Intervals
- Two extra LightGBM quantile models (α = 0.1 / 0.9) give the P10–P90 band.
- Decision layer
- Newsvendor: forecast + safety stock → production qty under capacity constraints.
- Evaluation
- Rolling-origin backtest; scored with the official M5 metric (WRMSSE).
Full study + benchmark vs. baselines: docs/forecasting-method.md.
4 · Retrain on new data
Retrain vs. forecast
Forecast uses the already-trained model to predict — instant. Retrain re-fits the model on the latest data (including anything you ingest) — that is the real training step, and it takes a few minutes on the full catalogue.