AI & ML Quick Path

Capstone 2 of 8

Store demand forecasting

Machine learningIntermediateEffort 20–30 h (estimate)

Business requirement

A retail chain wants next-14-day demand per product per store so it orders enough stock without filling the warehouse.

Lessons to finish first

Architecture

  1. Synthetic daily sales with trend, weekly pattern and promotions
  2. Time-based train/validation split
  3. Naive and seasonal-naive baselines
  4. Feature model (lags, day of week, promotions)
  5. Backtest over several windows
  6. Forecast file and error report

Build steps

  1. Generate two years of daily sales for 10 products in 3 stores, with weekly seasonality, holidays and promotions.
  2. Plot one series and describe trend, seasonality and noise in words.
  3. Split by time: train on the past, validate on the most recent weeks (never shuffle).
  4. Build two baselines: yesterday’s value and the same day last week.
  5. Train a gradient-boosting model on lag features, rolling means, day of week and promotion flags.
  6. Backtest over at least four rolling windows; report MAE and the share of days under-forecast.
  7. Produce a 14-day forecast with a simple uncertainty band (for example from backtest errors).

Python route and .NET route

Python
pandas (date features, shift, rolling), scikit-learn HistGradientBoostingRegressor, matplotlib for plots. The time-series demo in the examples folder is the starting point.
.NET (C#)
ML.NET Microsoft.ML.TimeSeries (ForecastBySsa) for single series, or FastTree regression on lag features for many series; write results with CsvHelper or plain File APIs.

Example input and output

Input
store S2, product P7, history to 2026-10-31
Output
14 rows: date, forecast, low, high

Data

Synthetic daily sales generated with a script (known seasonality so you can check the model finds it).

Starter file structure

Structure (Python file | .NET project)
forecast/
  data/generate.py
  features.py
  backtest.py | Backtest/Program.cs
  forecast.py
  README.md

Tests

  • No future data in any feature (lags only use past days)
  • Model beats seasonal-naive on backtest MAE
  • Forecast file has exactly 14 future dates per series

How it will be judged

  • Time-based validation used correctly
  • Errors reported per product and overall
  • Business reading of the error (stock-outs versus overstock)

Security and privacy

Sales data is commercially sensitive: keep it out of public repositories and logs.

Definition of done

  • Backtest table with baselines and model
  • A 14-day forecast with bands for every series
  • Written note on where the model fails

Stretch goals

  • Forecast at weekly level and compare
  • Add weather or holiday features
  • Retrain automatically when error rises

What to show an employer

Backtest chart for one product with actual versus forecast and the baseline.

Completion

Saved in this browser only.