Part III — Advanced Systems · Chapter 18 · Lesson 7 of 7 · 3 min read
Chapter 18 Checkpoint: Monitored Demand Forecast
Checkpoint level: Advanced
Goal. Build an end-to-end, monitored demand-forecasting service for a multi-store retailer. It must ingest daily sales, validate and repair the series, select and backtest methods per store, produce 28-day forecasts with prediction intervals, reconcile them to region and national totals, publish chart-ready output, and monitor its own accuracy and health over time.
18C.1 Required pipeline
- Ingest. Load order events (UTC) and the store master. Use the connector and SQLite patterns from Chapter 17 for at least one source.
- Validate. Apply the Lesson 1 checks per store. Stop the run on duplicate timestamps or schema violations; continue with warnings on gaps.
- Regularize and repair. Build the full store-by-date panel in local time, restrict to active life, classify gaps, and repair only short missing observations, flagging every repair.
- Features and diagnostics. Add calendar features, lags, and rolling statistics; decompose each store to confirm the weekly pattern.
- Backtest and select. Backtest at least four baselines with rolling origins and a 28-day horizon; select per store with the simplicity rule.
- Forecast. Produce 28-day point forecasts with failure isolation and fall-backs.
- Intervals. Add 80% and 95% empirical bands per horizon; clip at zero.
- Reconcile. Reconcile bottom-up to region and national level with aggregate intervals.
- Publish. Write the long, versioned output schema of Lesson 6, including recent actuals.
- Monitor. Record run health and, once actuals arrive, rolling accuracy against earlier runs.
18C.2 Monitoring requirements
- Run health: number of series, fall-backs, failures and reasons, gaps repaired, longest unrepaired gap, and run duration.
- Accuracy tracking: for each published run, compute WAPE, MASE, and bias once actuals are available, by horizon and level.
- Coverage tracking: share of actuals inside the 80% and 95% bands, by horizon.
- Drift alerts: alert when rolling 4-week WAPE exceeds the backtest WAPE by a set margin, when bias stays on one side for three consecutive weeks, or when 80% coverage falls below 70%.
- Data alerts: alert when a store's feed is missing for the latest day or volume falls outside its rolling anomaly bounds.
18C.3 Acceptance tests
- Validation detects an injected duplicate day and an injected unsorted block.
- A store with a deliberately corrupted series falls back and the run still completes.
- No feature, preprocessing step, or seasonal index uses data after the backtest origin (a leakage test asserts this for every origin).
- Forecasts for stores sum exactly to the region and national point forecasts.
- Empirical 80% coverage on a held-back window is between 72% and 88%.
- The output passes schema validation, and rerunning with the same inputs and configuration produces identical results.
- Every chosen method beats or ties seasonal naive (MASE ≤ 1.0) for at least 80% of stores, and the run report lists the exceptions.
18C.4 Assessment rubric
| Area | Weight | Evidence of mastery |
|---|---|---|
| Data validation and repair | 20% | Gaps classified with operational data; repairs limited and flagged |
| Evaluation honesty | 25% | Chronological backtests, leakage tests, metrics chosen from business cost |
| Forecast quality | 15% | Clear improvement over seasonal naive where claimed; simplicity rule applied |
| Uncertainty | 15% | Per-horizon bands with measured coverage and width |
| Engineering | 15% | Isolation, determinism, versioned output, reconciliation |
| Monitoring and communication | 10% | Actionable alerts and a readable run report |
Completion standard. All acceptance tests pass on the provided sample data, the run report and leaderboard are produced automatically, and every illustrative API call has been confirmed against the module reference of your installed PeaLang version or replaced with its documented equivalent.
Reflection. Which store was hardest to forecast, and was the difficulty in the data, the method, or the evaluation? Which alert would you trust enough to page someone at night?
Chapter summary. Time-series work starts with a validated, regular index and features computed without looking ahead. Windows, repairs, and decomposition make a series understandable; chronological backtests and cost-based metrics make claims honest; baselines set the bar; and grouped forecasts with verified intervals, reconciliation, versioned output, and monitoring turn a model into a service.
Transition to Chapter 19. The forecasting baselines of this chapter are the benchmark for the machine-learning foundations of Part IV. Chapter 19 begins with the ML layer's datasets, features, and model contracts.
Checkpoint status: Ready for review.