Implementation of Demand Forecasting
Demand forecasting in retail and manufacturing is a classic operational management task. Underprediction leads to stockouts and lost sales. Overprediction causes excess inventory and write-offs. ML approach compared to ARIMA and expert methods reduces MAPE by 20-40% with proper implementation.
Task Specifics
Forecasting Hierarchy: Usually need forecasts at multiple levels simultaneously:
- Company → division → category → SKU → SKU × warehouse
- Temporal coherence: sum of SKU forecasts must match category forecast
Reconciliation methods: bottom-up (aggregate from bottom), top-down (distribute from top), MinT (Minimum Trace) — mathematically optimal.
Scale: Retailer with 10,000 SKU × 50 warehouses × 365 days = 182.5M forecasts per year. Individual model per SKU-warehouse — unrealistic. Need global models.
Modeling Approaches
Global Deep Learning Models (recommended for large retail):
- DeepAR (Amazon): Autoregressive RNN, works as global model across all SKUs
- N-BEATS / N-HiTS: interpretable neural networks specifically for time series
- Temporal Fusion Transformer (TFT): state-of-the-art for hierarchical forecasting with known covariates
Advantage: single model trained on all SKUs and extracts common patterns (weekend patterns work for most products).
Gradient Boosting for Retail: LightGBM with lag features — often best speed/accuracy tradeoff:
- Lag features: sales t-1, t-7, t-14, t-28, t-365
- Rolling stats: mean, median, std for 7/28/90 days
- Calendar: day of week, month, week of year, holidays
- Price and promo flags: current price, discount %, promo flag
Intermittent Demand (rare sales): Croston's method, ADIDA, IMAPA — special methods for SKUs with sparse sales (sporadics). Wrong methods give catastrophic errors for these items.
External Factors
| Factor | Source | Impact |
|---|---|---|
| Promo Activity | Trade calendar | +50-300% during promotion |
| Holidays | Calendar + HR | Category-specific |
| Weather | OpenWeatherMap API | Seasonal items ±30-50% |
| Competitor Pricing | Parsing / DataWeave | Demand elasticity |
| Trends | Google Trends | New items without history |
Promo-lift model — critical component: need to predict not just baseline demand, but incremental demand from specific promo mechanism (10% discount vs. 2+1).
Production Forecasting
In manufacturing, task becomes more complex:
- Demand forecast → production plan → raw material purchase plan
- Production capacity as constraint
- Supplier lead time: demand in 3 months determines order now
MRP II / APS systems (SAP PP, OMP, Kinaxis) integrate with ML forecast via API or file exchange. AI provides forecast, APS translates to production plan accounting for capacity.
Metrics and Backtesting
Correct Backtesting — Walk-Forward Validation:
- Train on data until date D
- Forecast on horizon H (28 days)
- Move forward H, repeat
- Average errors across all periods
Metrics:
- MAPE: drawback — explodes at small values (division by 0)
- SMAPE (Symmetric MAPE): more robust
- RMSSE (Root Mean Squared Scaled Error): normalized by naive forecast
- Bias: systematic over/under-forecast (important for inventory management)
SCM Integration
- SAP S/4HANA: IBP (Integrated Business Planning) has native ML integration or forecast import
- Oracle SCM: forecast import via REST API into Demand Management
- Custom WMS: direct PostgreSQL write / API endpoint
Timeline: global LightGBM model with basic features for 1,000-10,000 SKU — 4-6 weeks. Hierarchical forecasting with promo-lift and SCM integration — 4-6 months.







