Home▸Articles▸Time Series and Forecasting

Demand Forecasting

End-to-end guide to demand forecasting - from data preparation to hierarchical models, evaluation, and production deployment.

mysimulator teamUpdated 2026-01≈ 5 min read▶ Open the simulation

Demand forecasting predicts how much of a product or service will be needed in the future. It drives inventory planning, staffing, pricing, and supply chain decisions. Getting it wrong means either stockouts (lost sales) or overstock (wasted capital).

Where It Is Used

Demand forecasting is critical across industries:

Products: Amazon fulfillment, Uber surge pricing, Walmart inventory, Starbucks staffing.

Typical Data You Will See

Aspect Typical Values
Granularity Hourly, daily, weekly
History length 2-5 years
Entities 1K to 1M SKUs/locations
Exogenous features 10-50 variables
Forecast horizon 1 day to 52 weeks

Common table structure:

date | sku_id | location_id | sales_qty | price | promo_flag | stock_level

External data sources: - Calendar features: holidays, events, weekdays - Weather data: temperature, precipitation - Marketing: promotions, campaigns, ad spend - Economic indicators: GDP, consumer confidence - Competitor actions: pricing, launches

What You Do in Practice

  1. Define forecast scope - What entities, what horizon, what frequency?
  2. Gather historical data - Sales, inventory, stockouts, external factors
  3. Handle data issues - Missing days, zeros vs stockouts, outliers
  4. Identify patterns - Trend, seasonality, holiday effects, promotions
  5. Build hierarchy - Product categories, regions, aggregation levels
  6. Train baseline model - Simple exponential smoothing or seasonal naive
  7. Add ML models - Gradient boosting with lag features, or deep learning
  8. Reconcile forecasts - Ensure hierarchy consistency (store forecasts sum to region)
  9. Evaluate properly - Time-based splits, multiple horizons, business metrics
  10. Deploy and monitor - Track accuracy by segment, retrain on schedule

Baseline First

Two baselines every forecasting project needs:

  1. Seasonal naive: Predict same value as same period last year
  2. Captures yearly seasonality
  3. No tuning required
  4. Often surprisingly competitive

  5. Simple exponential smoothing: Weighted average of recent observations

  6. Captures level and trend
  7. Three parameters to tune
  8. Fast to compute

If your ML model cannot beat seasonal naive by 10%+, investigate data quality before adding complexity.

Common Models and When to Choose

Model Best For Limitations
Exponential Smoothing (ETS) Single series, clear patterns No external features
ARIMA/SARIMA Statistical analysis, confidence intervals Complex tuning, slow
Prophet Business data with holidays, multiple seasonalities Can overfit, slow at scale
XGBoost with lag features Many features, complex interactions Requires careful feature engineering
LightGBM Large scale, fast training Same as XGBoost
DeepAR Many related series, learned patterns Requires significant data
Temporal Fusion Transformer Complex multi-horizon, interpretability Computationally expensive
N-BEATS Strong benchmark, no feature engineering Black box

Industry default: Start with ETS or Prophet for baselines, move to gradient boosting or deep learning for production.

Feature Engineering Patterns

Lag features: - Sales 1, 7, 14, 28, 364 days ago - Rolling mean/std over 7, 28, 90 days - Difference from same period last year

Calendar features: - Day of week, month, quarter (cyclical encoding) - Holiday indicators (with lead/lag effects) - Payday indicators, school holidays

Promotional features: - Promo active flag - Discount depth - Days since/until promotion - Promo type encoding

External features: - Weather (temperature, rain probability) - Events (sports, concerts, local events) - Economic indicators

Hierarchical features: - Category-level trends - Store-level seasonality - Cross-series patterns

Evaluation and Metrics

Primary metrics:

Metric Formula Use Case
MAPE Mean Absolute Percentage Error Easy to interpret, but fails on zeros
WMAPE Weighted MAPE Handles volume differences
RMSE Root Mean Squared Error Penalizes large errors
MAE Mean Absolute Error Robust to outliers
Bias Mean Error (signed) Detect systematic over/under forecasting

Business metrics: - Service level: % of demand fulfilled - Inventory turns: How fast stock rotates - Stockout rate: % of time out of stock - Overstock cost: Capital tied in excess inventory

Pitfalls: - Evaluating only on aggregate (hides poor SKU-level performance) - Using MAPE when zeros are common - Not evaluating at the horizon that matters for decisions - Ignoring bias (systematic over or under forecasting)

Failure Modes and Debugging Checklist

Production Checklist

Before deployment: - [ ] Backtesting across multiple time periods - [ ] Performance acceptable across all hierarchy levels - [ ] Cold start strategy for new products - [ ] Outlier handling defined - [ ] Forecast intervals generated (not just point forecasts)

After deployment: - [ ] Daily accuracy monitoring by segment - [ ] Bias tracking (directional errors) - [ ] Automatic alert on accuracy degradation - [ ] Weekly/monthly retraining schedule - [ ] Feedback loop with actual sales data - [ ] Human override capability for special events

Tools and Stack

Category Tools
Statistical models statsmodels, Prophet, statsforecast
ML models XGBoost, LightGBM, scikit-learn
Deep learning PyTorch, GluonTS, Darts, NeuralForecast
Scalable forecasting Spark, Ray, Dask
Visualization Plotly, matplotlib
Production Airflow, MLflow, cloud ML platforms

Example Mini-Case

Scenario: Grocery retailer needs daily SKU-level forecasts for 10K products across 200 stores.

Data: 3 years daily sales, promotions, holidays, weather.

Approach: 1. Baseline: Seasonal naive (same day last year) - WMAPE 35% 2. Feature engineering: Lag features, promo indicators, holiday effects 3. Model: LightGBM with 28-day forecast horizon 4. Hierarchy: Trained at SKU-store level, reconciled to category and store totals 5. Result: WMAPE 22%, 37% improvement

Production setup: - Nightly batch job computing next 28 days - Weekly model refresh - Daily accuracy dashboard - Alerts on WMAPE > 30% for any category

Business impact: 15% reduction in stockouts, 8% reduction in overstock.

Related Pages

Further Reading

Try it live

Everything above runs in your browser — open Demand Forecasting Simulator and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Demand Forecasting Simulator simulation

What did you find?

Add reproduction steps (optional)