Chapter 5 — Forecast¶
5.1 — The chain, and how to run it¶
⚙ Processes: the
forecaststep runs the whole statistical chain internally (outlier → characterization → backtest → best-method → forecast), thencausalandmaintenancechain after it;indirect-demand(the rollup) andnettingare SEPARATE steps (the two-pass design — gross pass 1 before netting, netted pass 2 inside it). Run: the ProcessRunner cards (each step standalone), or the full pipeline run (the API/CLI equivalents are in 5.D). The series scenario'sforecast_modedecides the statistical branch:native(absent = the full chain) orexternal(5.6 — no statistical forecasting at all).Weekly demand master.demand_actuals → outlier correction (5.3) → characterization (4.2) → backtest candidate methods (× metrics per series) → best method selection (+ locked overrides) → forecast point + quantiles PIPE_forecast_point_values → causal + maintenance chained after → indirect-demand (5.7) then netting (5.8)
Outputs of the chain (all CH, pipeline + series-scenario + archive scoped): the corrected training demand
(PIPE_demand_corrected), the backtest metrics (PIPE_series_backtest_metrics), the chosen
method per series (PIPE_series_best_methods), the point + quantile forecasts
(PIPE_forecast_point_values — planning-anchored forecast_week: point i
= planning Monday + i weeks for every series; consumers must use the stored dates, never re-derive them), the
fitted distributions (PIPE_fitted_distributions), and the per-(series, method) hyperparameters
(PIPE_forecast_hyperparameters).
5.2 — Statistical forecasting¶
⚙ Process: inside the forecast step (
utils/orchestrator.py+ the method families inforecasting/). Configured through the series scenario: method-selection pools + confidence levels + demand-horizon limits (the Method Selection fold, Fig. 15), per-segment forecast parameter sets and per-series hyperparameter overrides (Method Lab — the series page's "Method Lab & Hyperparameters" panel, single-method Run cards, Fig. 18).
All methods — and the library behind each (verified against the runner imports):
| Method | Family / file | Library | Notes |
|---|---|---|---|
AutoARIMA · AutoETS · AutoTheta · AutoCES |
Statistical — forecasting/statistical_models.py |
Nixtla StatsForecast | The auto* selection wrappers; single-season methods take max(seasonal_periods) |
Naive · SeasonalNaive · HistoricAverage ·
SeasonalWindowAverage |
The baselines — always eligible, the sanity floor every candidate must beat | ||
MSTL |
Multiple-season decomposition (needs the optional supersmoother package — loud
unavailability if absent); sees the real yearly cycle after zero-fill (3.3) | ||
SeasonalHurdle |
Statistical (pure-Python) | none — project-implemented (characterization.py registration) |
The only model that predicts the zeros-off-season shape — see the description below |
LightGBM · XGBoost |
ML — forecasting/ml_models.py |
LightGBM (LGBMRegressor, quantile objective) ·
XGBoost (XGBRegressor) |
Gradient boosting over engineered windows; the covariate consumers — the exogenous
features (incl. CF:{code} customer forecasts) enter here; one model per series; gated by
sufficient_for_ml |
NHITS · NBEATS · PatchTST · TFT ·
DeepAR |
Neural — forecasting/neural_models.py |
Nixtla NeuralForecast (PyTorch / Lightning; MQLoss quantiles) | Optional dependency (explicit import guard); accepts future exogenous features; gated by
sufficient_for_deep_learning |
Chronos |
Foundation — forecasting/foundation_models.py |
Amazon Chronos (chronos-forecasting, T5 checkpoints) |
Zero-shot; config-gated (forecasting.chronos.enabled) |
ExternalForecast |
The branch, not a model | — | 5.6: the external mode materializes the customer's master-data forecast under this method name |
SeasonalHurdle — the zeros-off-season / short-ON-window forecaster
(pure-Python, no library — generic models smear demand across the off-season; this is the only method that predicts the "zeros in winter, a spike in summer" shape):
- ON-window: the ISO weeks-of-year where the series has EVER had nonzero demand
(computed at fit; overridable per series via
on_weeks). - Level: the per-week-of-year historical average of each ON week, optionally rescaled by
level_scale. Zero outside the window. - Quantiles: a deterministic point map (no distribution fitting).
- Guards: needs ≥ 2 nonzero observations and
n_obs ≥ season_length. - Verified live (the demo tenant, 18 nonzeros over 3 summers): future zeros weeks 1–43, ramp weeks 44–53, Jun ≈ 1,587 and Jul ≈ 2,896 — matching the historical weekly averages.
Registered in all five characterization demand-group pools by default; editable per series in Method Lab (on_weeks, level_scale).
Which methods a series even tries is decided upstream: the characterization demand-group pools (4.2), the
ML/DL sufficiency gates, and the horizon-limit min_periods (3.3).
The hyperparameters, method by method¶
What a planner can modify per method (the Method Lab / Hyperparameters panel, Fig. 18; the per-series
overrides persist in interact_series_hyperparameters_overrides). Every method additionally carries
the two horizon-limit overrides (min_periods 0 = inherit, below_min_policy skip |
zero_fill — 3.3), not repeated per row below.
Classical statistical family (StatsForecast's auto* wrappers):
| Method | Hyperparameter | Default | What it does / example |
|---|---|---|---|
| AutoARIMA | season_length | 52 | The seasonal cycle the ARIMA search assumes. Example: a monthly-seasonality weekly series → set 12 instead of 52 or the seasonal terms chase the wrong cycle |
max_p / max_q | 5 / 5 | Search ceiling for the AR (autoregressive) and MA (moving-average) orders. Raise for slowly-decaying patterns; the auto search picks the best within the box | |
max_P / max_Q | 2 / 2 | The seasonal counterparts of p/q | |
max_d / max_D | 2 / 1 | Max differencing (how hard the model may flatten trend/seasonality) | |
stepwise | true | Stepwise (fast) vs exhaustive (slower, wider) order search | |
approximation | false | Approximate AIC — faster, coarser picks | |
Example: a strongly trended series → max_d 2,
stepwise on — the search finds the trend differencing itself | |||
| AutoETS | season_length | 52 | As above |
model | 'ZZZ' | Error/Trend/Season type triple, Z = auto. Example: force multiplicative seasonality with
season_length 52 + model 'ZZM' when additive winters go negative | |
damped | null (auto) | Allow the damped-trend variant (long flat tails) | |
| AutoTheta | season_length | 52 | As above |
decomposition_type | multiplicative | Switch to additive for low-volume series where multiplicative decomposition explodes | |
| MSTL | season_length | 52 | The primary cycle to decompose |
iterate | 2 | Decomposition iterations — more refines multiple overlapping cycles (e.g. 4 + 52) at some cost | |
| CrostonOptimized | alpha | 0.1 | Intermittent-demand smoothing. Example: burstier intermittent series → 0.3 reacts faster to demand-size changes |
SeasonalHurdle (the project's pure-Python method — the two knobs are its whole shape contract):
| Hyperparameter | Default | What it does / example |
|---|---|---|
on_weeks |
empty = infer | The ISO weeks that may hold demand, comma-separated. Example: a summer-only series → "25,26,27,28,29,30,31,32,33,34" pins the ON-window explicitly instead of trusting the history's ever-nonzero weeks |
level_scale |
1.0 | Multiplies the per-week historical average. Example: planning a promotion year → 1.15 plans 15% above the raw historical level inside the same window |
ML family (gradient boosting over engineered lag windows):
| Hyperparameter | LightGBM default | XGBoost default | What it does / example |
|---|---|---|---|
lags |
12 | 12 | How many past weeks each training row sees. Example: a yearly pattern → raise to 52 so the model can learn the same-week-last-year signal |
n_estimators |
100 | 100 | Number of boosted trees. Example: underfitting → 300 with a lower learning rate for a smoother model |
learning_rate |
0.1 | 0.1 | Step shrinkage — lower = slower learning, less overfit (pair it with more trees) |
num_leaves |
31 | — | LightGBM's tree complexity knob — more leaves = finer interactions, more overfit risk |
max_depth |
−1 (auto) | 6 | Tree depth — the classic overfit lever; 6–8 is usually plenty on weekly series |
feature_week_of_year / feature_month / feature_day_of_week |
true / true / false | true / true / false | The calendar features fed as covariates (sin/cos encoded). Turn day-of-week on for non-aggregated daily remnant series; week-of-year off when the series has no annual cycle to avoid spurious seasonality |
Neural family (NeuralForecast — training-shape knobs, same three questions: how much history, how long to train, how fast):
| Hyperparameter | NHITS / NBEATS | PatchTST | TFT | DeepAR | What it does |
|---|---|---|---|---|---|
input_size |
48 | 64 | 48 | 48 | Weeks of history per training example. Example: raise to 104 for two full years so the net sees the annual cycle twice |
patch_len / stride |
— | 16 / 8 | — | — | PatchTST slices history into attention patches — patch_len 16 = it attends to ~4-week chunks |
n_layers / d_model / n_heads |
— | 3 / 128 / 4 | — | — | PatchTST's transformer width — capacity vs training time |
hidden_size / encoder_hidden_size / layers |
— | — | 64 | 64 / 2 | TFT/DeepAR's recurrent width and depth — same trade-off |
max_steps / learning_rate / batch_size |
1000 / 0.001 / 32 | 1000 / 0.001 / 32 | 1000 / 0.001 / 32 | 1000 / 0.001 / 32 | The training budget trio — more steps + lower LR = better convergence at training cost |
dropout_prob_theta / dropout |
NHITS: 0 | — | 0.1 | — | Regularization — raise when a small training set overfits |
HistoricAverage and ExternalForecast have
no tunable hyperparameters (their entries exist empty); AutoCES, Chronos, Naive, SeasonalNaive and
SeasonalWindowAverage expose none — they run on their built-in defaults (Chronos only via its config gate,
forecasting.chronos.enabled).
Best fit. Every candidate method is backtested per series (windows + sMAPE/MAPE metrics stored
in PIPE_series_backtest_metrics); the winner lands in PIPE_series_best_methods
(best_method + locked_method — a planner lock wins over the backtest). "The" forecast of a
series = its best/locked method's rows. Feature-based: the feature-reliability + customer-forecast
steps score the CF:{code} customer forecasts (scale-invariant reliability in pipe_feature_reliability,
PG-only) and the ML/DL families consume them as covariates — a series with a reliable customer forecast gets a
feature-driven candidate instead of a purely statistical one.
Consumers (verified against the code — condensed):
| Consumer | Meaning |
|---|---|
| Netting (5.8) | Reads the statistical forecasts for firm-demand consumption via _load_stat_forecasts; causal and maintenance streams read their own tables. |
| The rollup (5.7) | Reads best-method forward rows for good_replenishment; causal rows seed their own stream via _load_causal_forecast_rows. |
| MEIO | Forecast-basis mode sizes on the best-method path (gross or netted per demand_basis_direct), plus zone context and delivered-fill diagnostics. |
| Bad forecast (the wash loop, 7.8) | Reads the demand union of every stream via _load_all_demand. |
| Supply + allocation | Reads netting's supply_plan_qty (5.8), never the raw forecasts. |
| API surfaces | Series pages, Dashboard aggregate demand, sparklines, forecast-SKUs, exceptions, overview map, K-curve EOQ, NPI donor forecasts, retirement burn-down/LTB, constraints projection, alerts, and Mirabelle all consume the resolved best-method forecast. |
| Result approval | The forecast approval gate (10.5) certifies released archives; it does not compute them. (The Scenario Review freeze and the standalone archiver were removed Dec 2026.) |

Fig. 18 — The forecast review surface (the demo tenant, series 9102912_900000005 "the customer Standard Crate (Serviceable)"): the history + forecast chart with confidence bands, the consensus forecast grid (Statistical / Adjustment / Override sub-rows, the Customers group), and the per-method Method Lab & Hyperparameters panel below (single-method Run cards + the per-series overrides). Captured 2026-11-10.
5.3 — Outlier detection & demand correction¶
⚙ Process: the first phase inside the forecast step (
outlier/detection.py). Output:PIPE_demand_corrected(the corrected training series + what was changed). Configured per segment via the outlier parameter sets (the series scenario's Outliers fold).
Three detection methods with four correction modes (clip — the default — interpolate, rolling median, none). Consumers — the corrected demand IS the forecast's basis, and through it the whole plan's:
| Consumer | Meaning |
|---|---|
| The forecast chain (direct) | step_outlier_detection returns the corrected dataframe; characterization, backtest, best-method selection, and forecasting all train on corrected demand. |
| Everything the forecast feeds (transitive) | Netting, supply, allocation, K-curve, and dashboards consume the corrected-trained forecast; the characteristics-derived date_range_end cutoff is corrected too. |
| Exceptions / alerts (transitive) | Covariability, observation-count, and recency checks read characteristics computed on the corrected series. |
| Series Outlier tab / Mirabelle | The corrected-vs-original comparison is shown; “outlier” queries read the correction table directly. |
| MEIO actuals-basis statistics — honest gap | MEIO still reads raw master.demand_actuals for rates, σ, empirical distributions, and βline hit statistics; a corrected forecasting spike can therefore still inflate MEIO variability. This is the documented 5.3.1 design decision. |
Design decision pending (planner): MEIO's demand-statistics source.
The corrected demand is the forecast's training basis — but MEIO's actuals-basis sizing still sees the RAW demand. Option A: an opt-in MEIO scenario parameter demand_stats_source: 'actuals' (default) | 'corrected' — the meio_runner demand loaders read PIPE_demand_corrected (archive-pinned) when 'corrected', pairs outside the forecast universe keep raw loudly; default 'actuals' keeps every tenant byte-identical. Option B: keep raw and adopt the stance "actuals are facts — corrections are training-noise handling" (zero code change). The open policy question inside A: WHICH series scenario's corrections MEIO reads, and whether an empirical distribution on corrected data under-represents genuine volatility — a documented trade-off.
Worked examples — one per detection method (defaults: IQR k=1.5, Z threshold 3, STL residual threshold 3)¶
1 · IQR + clip (the default method — a 12-week series with one data-entry spike; the flagged week is red):
| W1 | W2 | W3 | W4 | W5 | W6 | W7 | W8 | W9 | W10 | W11 | W12 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| initial | 10 | 12 | 11 | 13 | 10 | 11 | 12 | 10 | 60 | 11 | 12 | 10 |
| result (clip) | 10 | 12 | 11 | 13 | 10 | 11 | 12 | 10 | 15 | 11 | 12 | 10 |
sorted: [10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 60]
Q1 = 10 Q3 = 12 IQR = 2
lower = Q1 - 1.5 x IQR = 7 upper = Q3 + 1.5 x IQR = 15
W9: 60 > 15 -> outlier -> clipped to the upper bound 15
2 · Modified Z-score (median/MAD) + clip — the default Z variant is MAD-based, which is why one huge spike does not mask itself (a mean/std Z would: on this series mean=33.7, std=38.8 → z(150) = exactly 3.0 — right at the threshold, barely flaggable):
| W1 | W2 | W3 | W4 | W5 | W6 | W7 | W8 | W9 | W10 | |
|---|---|---|---|---|---|---|---|---|---|---|
| initial | 20 | 21 | 20 | 22 | 21 | 20 | 150 | 21 | 20 | 22 |
| z-score | -0.7 | 0 | -0.7 | 0.7 | 0 | -0.7 | 87.0 | 0 | -0.7 | 0.7 |
| result (clip) | 20 | 21 | 20 | 22 | 21 | 20 | 25.4 | 21 | 20 | 22 |
median = 21 MAD = 1.0 MAD_scaled = 1.4826
bounds: 21 +/- 3 x 1.4826 = [16.55, 25.45] threshold: |z| > 3
W7: z = 87 -> outlier -> clipped to 25.45
3 · STL residuals + clip (illustrative numbers) — for seasonal series the raw bounds are misleading (a seasonal peak would look "out of bounds" to IQR/Z); STL first removes the pattern, then judges the residuals. A 36-week seasonal series with a +45 spike on one peak week — the weeks around the spike:
| W13 | W14 | W15 (spike) | W16 | W17 | |
|---|---|---|---|---|---|
| seasonal expectation | ~106 | ~124 | ~125 | ~124 | ~110 |
| observed | 108.7 | 122.5 | 174.2 | 125.6 | 109.5 |
| residual | +2.7 | -1.5 | +45 | +1.6 | -0.5 |
STL(robust, period=12): series = trend + seasonal + residual
typical residuals: +/- 2 (the noise scale) residual median ~= 0, MAD ~= 1.5
modified z on residuals: 45 / (1.5 x 1.4826) ~= 20 >> 3 -> W15 flagged
bounds (1st/99th percentiles of the original): [52, 159]
result: W15 clipped 174 -> ~159; all normal seasonal peaks survive untouched
Honest behavior note (observed while computing these examples): robust STL downweights a large single spike and can smear part of it into neighboring residuals — with a big spike, weeks next to it may flag too. The residual threshold and the correction choice are what keep this benign; on very spiky series the MAD-based Z (example 2) is often the cleaner option.
4 · The IQR zero-ratio guard (the load-bearing protection — exact numbers): a sparse, zero-filled series (3.3) with two real demand weeks:
| W1 | W2 | W3 | W4 | W5 | W6 | W7 | W8 | W9 | W10 | W11 | W12 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| initial | 0 | 0 | 0 | 0 | 0 | 0 | 40 | 0 | 0 | 50 | 0 | 0 |
| with the guard | zero_ratio = 10/12 = 0.83 > 0.5 → IQR skipped entirely — the series passes through unchanged (40 and 50 survive: they ARE the signal) | |||||||||||
| without the guard | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
counterfactual: Q1 = Q3 = 0, IQR = 0 -> bounds [0, 0]
W7 and W10 both "outliers" -> corrected to 0 -> the demand is DESTROYED
(this is precisely the incident the guard exists for)
Correction modes (the outlier parameter set's correction_method):
| Mode | Meaning |
|---|---|
clip (default) |
Caps the flagged value at the method's lower/upper bound. |
interpolate |
Replaces the flagged value with the linear interpolation of its neighbours. |
median |
Replaces the flagged value with the rolling-window median. |
none |
Flags only; PIPE_demand_corrected records the flag and the value passes through unchanged — the “detect but don't touch” mode. |
5.4 — Causal forecasting¶
⚙ Process: the causal step (
causal/scenario_runner.py), chained after forecast. Output:PIPE_causal_forecast(CH; PG-side scenario rows synced per run). Configured on the Causal page (/causal) — scenarios, fleet plans, usage, deployments, failure rates, coverage, causal BOM, in W/M/Q/Y granularity (the overlap-prorated range-join).
Input tables (the causal model's contract — reference layer in master.*,
scenario-scoped layer in {schema}.scen_causal_*):
| Table | Contents | Scope |
|---|---|---|
master.causal_asset_type |
The asset types (e.g. bike models) — code, name | Reference |
master.causal_usage_type |
The usage units — km_total, training_days, maintenance_days… |
Reference |
master.causal_bom |
Asset type → spare item: qty_per_asset, is_lru, repair_yield, the usage type the failure rate keys on |
Reference |
{schema}.scen_causal_fleet_plan |
How many assets of each type each customer holds, over a period (asset_qty, period_start/end) |
Per scenario |
{schema}.scen_causal_asset_usage |
Per-asset usage factor over a period (km ridden, days…; usage_mode='fleet_total' = the fleet's total) |
Per scenario |
{schema}.scen_causal_asset_deployment |
Asset placed at a site from a date (qty) |
Per scenario |
{schema}.scen_causal_asset_coverage |
Which site covers which asset / asset type / customer: coverage_pct with a validity window |
Per scenario |
{schema}.master_causal_failure_rate |
The item's failure rate per usage unit (failures/km) per usage type, per period | Per scenario |
Worked example — real data (the demo tenant: item 17 Di2 Battery BT-DN300 + Charger Kit at site 201 France Country Warehouse, causal scenario 1 "Base Season 2025", week 2023-12-01):
| Input | Row(s) |
|---|---|
| causal BOM | 5 bike types carry the battery, qty_per_asset = 1, usage keyed on km_total (e.g. Canyon Ultimate CFR Disc → item 17) |
| fleet plan | Visma-Lease a Bike: 50 × CAN-ULT, 2023-11-29 → 2024-11-27 |
| usage | that week's fleet km: CAN-ULT rows 1,771.1 + 28,793.8 km (per-bike rows); the other types add ~137k km combined |
| failure rate | 6.6928e-07 failures/km for item 17, km_total, that period |
| coverage | site 201 covers the CAN-ULT type at 40% (validity window) |
per-bike sub-computation (one CAN-ULT): 28,793.8 km x 6.6928e-07 failures/km
= 0.01927 expected battery failures that week, before coverage routing
composition: demand(item, site, week) = SUM over bikes [ usage_km x failure_rate x qty_per_asset ]
x coverage_pct(site) (overlap-prorated across the period boundaries)
stored result: PIPE_causal_forecast scenario 1, week 2023-12-01: qty = 0.0893
(the full row reflects every covered bike's contribution routed by the coverage rules)
Modifying it — the simulation workflow. The causal scenario IS the what-if vehicle: the
/causal page's editors (Fig. 19) write the four scenario override sets
(fleet_overrides / failure_rate_overrides / usage_overrides /
coverage_overrides — auto-saving 800 ms) and the grid granularity (W/M/Q/Y with overlap-prorated
period matching). A simulation = clone or edit a scenario (e.g. "Fleet Expansion 2026": the fleet plan grows
from 50 to the expanded roster), re-run the causal step
(the Processes page's Causal card → Run), and compare — the causal results comparison and
the consensus grid show scenario against scenario, each partition tagged with its
scenario_id in PIPE_causal_forecast. Live pair on the demo tenant: "Base Season 2025"
(50-bike fleets) vs "Fleet Expansion 2026".
Consumers (verified): netting
(_load_causal_forecasts — the causal stream that can net against the statistical forecast per the
net/maint netting modes), the rollup's causal stream (_load_causal_forecast_rows), bad-forecast's
demand union, the API causal results/breakdown/aggregate surfaces, sparklines, the series consensus grid (the
Causal sub-rows), alerts, Mirabelle, and the forecast-approval gate family. (The freeze/historize copies were removed with those features, Dec 2026.)

Fig. 19 — Where causal demand is configured (the demo tenant — the only tenant with
causal rows, 48,280): the Causal page (/causal) — causal scenarios with their fleet plans, usage
grids, deployments, failure rates, coverage and causal BOM (auto-saving modals, W/M/Q/Y granularity with
prorated period matching). Captured 2026-11-10.
5.5 — Event-based (maintenance) forecasting¶
Use event forecasting when you already know what work is scheduled and want to know how many parts each site is likely to need, and in which week. The dates and job counts come from the schedule, not from sales history. A job can be scheduled even though some parts are only replaced after an inspection.
The example below is fictional: Winter service example, with two event types, three parts and two depots. The planning date is Monday, 7 December 2026. The workbook and the screenshots use the same example; no production or tenant data is needed.
Download the Excel workbook (.xlsx)
5.5.1 — Enter the schedule, parts and coverage¶
In Pipelines > Forecast, choose New Scenario > Maintenance or open an existing
maintenance scenario. Use these three tabs; the screenshots show the Mirabelle screens
populated with the example inputs. If an event is not in the list yet, first load it into
the event catalog through the maintenance_event import object.
Schedule: how many jobs, and when? Select the event, check it to include it in the
scenario, select dates, and enter the qty for each selected date. qty = 20 means
20 bikes receive the service on that date, not 20 event types or 20 spare parts.
| Event | Scheduled date | Jobs (qty) |
Week starting Monday |
|---|---|---|---|
| Pre-season service | Tue 8 Dec | 20 | 7 Dec |
| Pre-season service | Fri 11 Dec | 10 | 7 Dec |
| Safety inspection | Fri 11 Dec | 4 | 7 Dec |
| Pre-season service | Tue 15 Dec | 10 | 14 Dec |
Schedule: the Selected dates list shows the full quantity for each date even when
the calendar badge says 9+. Select Safety inspection to see its four jobs on 11 December.
BOM: what does one job use? The bill of materials (BOM) lists the parts for an event. Enter the Qty used when the part is replaced and the Likelihood % that the job needs that part. Multiply the two to get expected units per job.
| Event | Part | Qty if replaced | Likelihood | Expected units per job |
|---|---|---|---|---|
| Pre-season service | Brake pad set | 1 | 50% | 0.50 |
| Pre-season service | Drive chain | 1 | 25% | 0.25 |
| Pre-season service | Valve core | 2 | 100% | 2.00 |
| Safety inspection | Brake pad set | 1 | 100% | 1.00 |
BOM: one brake pad set on half the pre-season jobs gives 0.50 sets per job on average. Two valve cores on every job gives 2.00 per job.
Coverage: which depots supply those parts? Choose Create Scenario before setting Coverage. For each event, list the sites that supply it and enter their shares. The shares apply to every part on that event's BOM and every scheduled date for that event in this scenario. For this example, enter two site rows for Pre-season service, and only North Depot for Safety inspection.
| Event | North Depot | South Depot | Total |
|---|---|---|---|
| Pre-season service | 60% | 40% | 100% |
| Safety inspection | 100% | 0% (no site row) | 100% |
Check the Coverage total before running
Enter shares that total 100%. The engine uses the percentages as entered; a total of 90% allocates only 90% of the expected units. With no coverage rows at all, an occurrence is forecast only if it already has a site recorded on that occurrence. For jobs entered on the calendar, set explicit coverage, even if one site gets 100%.
5.5.2 — Work the numbers in Excel¶
Start with 20 Pre-season service jobs on 8 December. Take the Brake pad set row:
- Expected units per job:
1 set x 50% = 0.50. - Expected units for that date:
20 jobs x 0.50 = 10 setsacross both depots. - Split those units:
10 x 60% = 6for North Depot and10 x 40% = 4for South Depot. - Add rows for the same part, site and Monday. The other Pre-season date in that week
adds
10 x 1 x 50% x 60% = 3sets for North Depot. Safety inspection adds4 x 1 x 100% x 100% = 4. North therefore needs 6 + 3 + 4 = 13 sets for the week of 7 December. South needs 4 + 2 = 6 sets, with nothing from Safety inspection.
Here are all four Brake pad set rows before adding them into weeks:
| Date | Event | Jobs x qty x likelihood | Sets before split | North Depot | South Depot |
|---|---|---|---|---|---|
| 8 Dec | Pre-season service | 20 x 1 x 50% |
10 | 6 | 4 |
| 11 Dec | Pre-season service | 10 x 1 x 50% |
5 | 3 | 2 |
| 11 Dec | Safety inspection | 4 x 1 x 100% |
4 | 4 | 0 |
| 15 Dec | Pre-season service | 10 x 1 x 50% |
5 | 3 | 2 |
On the workbook's Event calculation sheet, follow row 8: E8*F8*G8 multiplies
jobs, quantity and likelihood; K8 = H8*I8 and L8 = H8*J8 split the result by site.
The formula zeros dates before the planning date. Weekly forecast uses SUMIFS to
add the rows that match each part and Monday, one depot at a time.
Weekly forecast worksheet (expected units):
| Week starting Monday | Part | North Depot | South Depot | Both depots |
|---|---|---|---|---|
| 7 Dec 2026 | Brake pad set | 13 | 6 | 19 |
| 7 Dec 2026 | Drive chain | 4.50 | 3 | 7.50 |
| 7 Dec 2026 | Valve core | 36 | 24 | 60 |
| 14 Dec 2026 | Brake pad set | 3 | 2 | 5 |
| 14 Dec 2026 | Drive chain | 1.50 | 1 | 2.50 |
| 14 Dec 2026 | Valve core | 12 | 8 | 20 |
A forecast of 4.50 chains is an expectation, not an instruction to order half a chain. Keep the decimals when adding dates and applying the site split. Ordering is a separate step.
Try moving a job to the following week
In Inputs, change the Pre-season service date in B9 from 11 to 18 December;
do not move the Safety inspection on the line below it. The North Depot brake pad
forecast goes from 13 and 3 to 10 and 6. The three sets move weeks, but the
two-week total stays at 16. In Mirabelle, change the dates in the scenario and rerun.
5.5.3 — Decide what goes into the supply plan¶
In Pipelines > Pipeline, edit the pipeline, select the Maintenance scenario in the Forecast column, and choose Add or Net. This setting belongs to the pipeline.
- Add if these jobs are extra demand not already represented in the statistical forecast. The maintenance quantity joins the open forecast.
- Net if the statistical forecast already includes demand from this kind of work. The scheduled requirement consumes overlapping open forecast, but its full quantity stays in the plan as firm-like demand. It is not a customer order.
The workbook's Add vs Net sheet follows Brake pad set at North Depot. To isolate the effect, both forecasts are unscaled, consumption is enabled and limited to the same week, and there are no customer orders, returns, approved replenishments or causal demand.
| Week starting Monday | Statistical forecast | Event forecast | Add: supply plan | Net: statistical consumed | Net: statistical left | Net: supply plan |
|---|---|---|---|---|---|---|
| 7 Dec 2026 | 18 | 13 | 31 | 13 | 5 | 18 |
| 14 Dec 2026 | 2 | 3 | 5 | 2 | 0 | 3 |
On 7 December, Add plans 18 + 13 = 31. Net consumes MIN(18,13) = 13 and plans
5 open + 13 scheduled = 18. The following week shows why Net does not cap the event at
the statistical forecast: it can consume only 2, but the plan still includes all 3
scheduled sets. With longer netting fences or carry,
consumption can also use forecast from other weeks.
5.5.4 — Run and check the result¶
- Select the pipeline that uses your maintenance scenario. Check the planning date and the pipeline's Weight fields. All-zero weights leave the streams unscaled in Netting, as in the worksheet. When the weights sum to a positive number, Netting scales each stream by its share of that total. A zero maintenance weight in that case excludes maintenance from the combined plan, even when a raw event forecast exists.
- In Process Runner > Processes, run Maintenance Forecast, then Forecast Netting
in workflow order. Under Dashboard > Forecast > Maintenance, review the scheduled
events and parts. Maintenance Events by Week counts distinct event/date entries:
the week of 7 December has three entries but 34 jobs. Use
qty, not the height of that bar, to calculate units. - Open the series for Brake pad set at North Depot and select Netting. Compare the maintenance forecast to Supply Plan week by week, not just the horizon total. If demand is missing, check that the scenario is linked, the dates are on or after the planning date, each part has a BOM row, and the right site has coverage.
Netting in Add mode (1-pass): in Week-by-Week Detail, Maint shows 13 and 3; Supply Plan shows 31 and 5. The KPI cards above sum the two weeks.
For a date or depot-split what-if, use a separate maintenance scenario and link it to the comparison pipeline. The BOM is shared by event, not copied with the scenario. Use a separate event definition if the what-if needs a different parts list or likelihood.
Where to check the inputs and raw forecast in the database
| Where | What to check |
|---|---|
PostgreSQL: master.maintenance_event and master.maintenance_bom |
Event name, part, units if replaced and likelihood stored as a fraction (0.50 for 50%). |
PostgreSQL: scen_maintenance_scenario_event_date and maintenance_event_coverage in the tenant's scenario schema |
Scheduled date, job count and depot shares stored as percentages (60 for 60%), for the linked maintenance scenario. |
ClickHouse: PIPE_maintenance_forecast |
Raw qty by item, site and Monday, before pipeline weights and netting. scenario_id here is the maintenance scenario ID. |
ClickHouse: PIPE_forecast_netting |
maint_forecast_qty is the maintenance stream after weighting, and supply_plan_qty is demand sent to supply planning. Use the Netting snapshot for the pipeline you are reviewing. |
To read the raw output, pass the pipeline ID, its linked maintenance scenario ID,
and the run's planning Monday as ClickHouse query parameters (archive_date is the
run bucket, not the week the work is due):
5.6 — External forecast (customer-provided)¶
⚙ Process: the same forecast step, branched: the series scenario's
forecast_mode='external'callsutils/external_forecast.py::materialize_external_forecastinstead of the statistical chain — no statistical forecasting is attempted. The master rows themselves arrive via the import (Point 2'sforecast_externalstep, from staging; the customer tenants stage them from DP-plan).
The scenario-level flag that ignores it — or not. The external forecast is pipeline-independent
master data; whether a planning configuration USES it is decided per scenario by the series forecast scenario's
forecast_mode (the Forecast Mode dropdown in the series scenario editor —
scen_forecast_scenarios.param_overrides, resolved by
utils/external_forecast.py::resolve_forecast_mode):
| Mode | Meaning |
|---|---|
native (default — also when the key is absent) |
IGNORE master.forecast_external entirely: the statistical chain runs unchanged (byte-identical baseline — the key is persisted ONLY when external, so native payloads never change) |
external |
USE it: no statistical forecasting attempted — the materialization branch runs |
| anything else | Fails loudly at run time with the editor hint (never a silent default) |
Where to find it in the UI¶
| To do this… | Go here |
|---|---|
| Switch between native and external · (decide whether the scenario uses the customer's forecast or the statistical chain) | The series scenario editor → the Forecast Mode dropdown (Pipelines → the pipeline's series scenario → Edit → the dropdown sits with the other scenario settings) |
| See the external forecast's results · (the materialized rows) | The series detail page → the Forecast tab: the chart shows the ExternalForecast method's forecast (a distinct color in the method legend). The consensus grid shows the same values |
| Load the external forecast data | The data arrives via the import process (Point 2) — the forecast_external import object lands the customer's CSV into master.forecast_external. There is no dedicated grid to browse the raw master rows (the data is viewed through the series forecast chart) |
master.forecast_external (PG, UNIQUE(item_id, site_id, Monday)) is the customer
forecast as master data. The materialization writes best-method rows under method
ExternalForecast + the point values, planning-anchored, byte-compatible row shapes — so every
downstream consumer (5.2's table) is unchanged. Fail-loud guards: empty forward master, lost xuid joins, the
frozen-archive refusal. Live: the customer tenant (3.19M rows / 44,541 series, backtest = 0 — the
external contract visible in the probe) and the customer (299,724 rows / 3,999 series).
Known granularity limit (design option pending)
the mode is scenario-wide — every series of the pipeline's series scenario follows it. There is no mixed mode today (e.g. "external for these items, statistical for those"); if that's needed, a per-segment forecast_mode override would be the natural extension (segment-scoped, resolved through the preprocess map, defaulting to the scenario's mode). Not implemented — flagged for the planner.
5.8 — Netting (forecast consumption)¶
⚙ Process: the netting step (
netting/forecast_netting.py::compute_and_persist) — also refreshed in-process as supply's pre-step (same code). Output:PIPE_forecast_netting(CH). Gated by theconsumption_enabledmaster switch (raw streams still display when off).
What it nets, against the statistical forecast: firm customer demand (the order book, from the
planning Monday — _load_firm_demand_orders), firm returns (confirmed
sales returns at the shipper), causal/maintenance (per the net modes), approved
replenishments (non-IB → install-base transfers — demand-side reduction + the engine's receipt
suppression, the double-count guard), and USE orders (the soiling formalization). Forward
consumption week-by-week from each commitment's date within the fence + carry; superseded items split at their
cutover (5.9). Result: supply_plan_qty = netted forecast + firm demand (+ net-mode maint/causal)
− firm returns − replenishment consumption — what the supply engine must actually fulfill.
The options (the netting parameter set on the forecast parameter set — pipeline-level; per-segment netting is intentionally unsupported):
| Parameter | Default | Meaning |
|---|---|---|
consumption_enabled |
true | The master switch — off: nothing is consumed, raw streams still display |
direction |
'forward' |
forward: a commitment at week T consumes T, T+1, T+2… ∓ backward: it consumes T, T−1, T−2… (an unknown value logs a warning and runs forward) |
forward_fence |
4 weeks | How far FORWARD a commitment can reach (offsets 0..fence) |
backward_fence |
0 weeks | How far BACKWARD (the backward-mode mirror) |
forward_carry_periods |
0 (disabled) | MRP-style carry-forward: after the fence pass, surplus forecast in the weeks just beyond the fence (fence+1 .. fence+carry) is pulled to satisfy still-unmet commitments |
backward_carry_periods |
0 (disabled) | The backward mirror: future surplus pulled backward to cover earlier commitments |
Worked example (computed with the real apply_consumption): a flat forecast of
100/week over 8 weeks, one firm order of 700 at W2, direction forward, fence 4, carry 2:
| W1 | W2 | W3 | W4 | W5 | W6 | W7 | W8 | |
|---|---|---|---|---|---|---|---|---|
| forecast | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| firm demand | 0 | 700 | 0 | 0 | 0 | 0 | 0 | 0 |
| consumed | 0 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| netted (open forecast) | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| supply_plan | 100 | 700 | 0 | 0 | 0 | 0 | 0 | 0 |
fence pass (fence=4): the W2 order reaches W2..W6 -> 5 x 100 = 500 consumed, 600 still unmet
carry pass (carry=2): the surplus beyond the fence, W7..W8 -> +200 consumed -> the 700 order is fully met
overrun (the fence-pass residual, kept for visibility): 600 at W2 — pre-carry by design
result: only W1's 100 forecast stays open; W2's supply_plan = the 700 firm demand itself
The same options, varied (consumed / netted rows, same inputs):
| Setting | W1 | W2 | W3 | W4 | W5 | W6 | W7 | W8 |
|---|---|---|---|---|---|---|---|---|
| fence=4, carry=0 — the limit visible | 0/100 | 100/0 | 100/0 | 100/0 | 100/0 | 100/0 | 0/100 | 0/100 |
| backward, fence=3 — consumes the past | 100/0 | 100/0 | 0/100 | 0/100 | 0/100 | 0/100 | 0/100 | 0/100 |
| consumption_enabled=false — nothing eaten | 0/100 | 0/100 | 0/100 | 0/100 | 0/100 | 0/100 | 0/100 | 0/100 |
The same mechanics are valid across conditions — good AND bad. One primitive
(apply_consumption), the same fence/direction/carry options, applied to every stream:
good — firm customer demand eats the statistical forecast (the example above) and approved
replenishments eat the install-base supply plan; bad — confirmed returns eat the
bad forecast (return_netted_qty) and planned/firm USE orders eat the
soiling stream (the use_return netting reuses the same consumption parity verbatim). The condition of
the flow changes what plays the role of "forecast" and "commitment"; the fence arithmetic never does.
⚙ Process: the netting step (
netting/forecast_netting.py::compute_and_persist) — also refreshed in-process as supply's netting pre-step (§3a in both engines: the MRP refreshes with a freshness skip — same archive cycle + max-age → "skipping pre-step" — while the LP always runs it). The netted rollup pass 2 (run_netted_reseed) is chained inside every netting execution. Output:PIPE_forecast_netting(CH). Gated by theconsumption_enabledmaster switch (raw streams still display when off).
How many times does netting run per cycle?
Up to twice: the netting step computes it, and supply's pre-step can refresh it before planning. MRP skips the refresh when the snapshot is fresh for the same planning cycle; LP refreshes it. Each execution also re-seeds rollup pass 2. The supply pre-step resolves the pipeline's linked series scenario. Older results can still include the former scenario-0 writer, so planning readers must not pool those rows with the linked scenario.
Statistical forecast + causal + maintenance → Firm demand (order book) → Firm returns + approved replen. + USE orders → PIPE_forecast_netting supply_plan_qty (open forecast) → Rollup pass 2 → MEIO → Supply → Allocation → K-curve → dashboards
Consumers (verified): allocation (load_demands reads supply_plan_qty — the
allocation demand IS the netted plan), both supply runners (MRP _load_sku_plans, the LP — with the
archive-pinned reads), the rollup pass 2 (the netted seeds), MEIO (netted-basis sizing +
install-base served), the K-curve items, the netting API surfaces (per-series, summary, aggregate, the
drill-down modals with PO/line + order-line details), the Dashboard netting strip, the inventory projection,
route-network coverage, the replay engine, alerts, and Mirabelle. Mirabelle Chat
uses the selected pipeline and its linked Series scenario for netting, not earlier writers'
results. See which plan Chat uses.

Fig. 20 — The netting review surface (the demo tenant, same series): the KPI panel (Consumed demand vs Consumed replen., Approved Repl., firm demand), the netting chart (consumption drawn inside the forecast stack, approved arrivals as dodged bars), and the weekly table — the KPI numbers open the order-line drill-downs. Captured 2026-11-10.
5.9 — Supersession demand migration (time-phased)¶
⚙ Process: no separate step — the time-phased migration is implemented once in
utils/supersession.pyand consumed at every level of this head: the forecast df migration (pre-forecast), the netting redirect (streams split at the cutover — buckets before it stay on the old item, buckets at/after move to the successor × demand_factor), the rollup split (both passes), MEIO's SKU drop after the date, and supply's safety-stock taper + BUY/MAKE blocking. The edges' master-data home — the table, the validation, the UI arrows, the import step — is 0.2 (Master Data).
"Behave normally until supersession — the SL is defined till the date, orders are cut at the date": the transition lives INSIDE the plan horizon. Fail-loud: an edge whose effective date falls in the horizon with a missing successor item aborts netting/rollup/supply with the exact remediation.
5.13 — The graphs, and the question each one answers¶
Every planning chart exists to answer one question. Read this as the legend of the app:
| Graph | How to read it |
|---|---|
| Series forecast chart (Fig. 18) | Where: Series page, Forecast tab. Question: what will demand be for this item at this site, and how uncertain is it? Read: left of the planning line is corrected history; right is the best/locked forecast. Shaded bands are configured confidence levels; a wide band means high σ and more safety stock. |
| Method Lab single-run chart | Where: Series page, Method Lab & Hyperparameters. Question: what would this method produce before I lock it? Read: compare one Run card per method, then lock the winner; a lock outranks backtest (5.2). |
| Backtest / method-explanation view | Where: Series page, method explanation and best-method badges. Question: how would each candidate have performed on actual history? Read: fitted-vs-actual overlays with sMAPE/MAPE; the argmin is “best fit”, unless a planner lock overrides it. |
| Outlier correction chart | Where: Series page, Outlier tab. Question: what did the detector change, and do I agree? Read: original and corrected series are overlaid; change the outlier parameter set or method when a correction is wrong. |
| Netting chart (Fig. 20) | Where: Series page, Netting tab. Question: how much of the forecast do firm commitments cover? Read: consumption is drawn inside the forecast stack; what remains is supply_plan_qty, approved arrivals are bars at arrival weeks, and KPI values open order-line drill-downs. |
| Aggregate demand chart | Where: Dashboard, Overview. Question: is demand rising or falling, and where does forecast replace history? Read: history runs to planning Monday, then summed best-method forecast; CH anchor-month exclusion prevents double counting. |
| Sparklines | Where: Series lists. Question: which series deserve a closer look? Read: history and forecast thumbnails expose trend breaks, dead series, and spikes. |
| Fitted / MC distribution view | Where: Series page, IO tab distribution panel. Question: what does demand uncertainty look like as a distribution? Read: the fitted or empirical demand-over-lead-time shape drives safety stock; a fat right tail means a larger service buffer. |
| Demand coverage map (Fig. 11) | Where: Dashboard, Demand tab. Question: who is served from where, and what should change? Read: customers (informational) and install bases are shown against warehouse targets; drag-drop and the coverage-routes modal write the real TRANSFER lanes (3.4). |
| Lead-time scatter + bootstrap histogram (Fig. 12) | Where: Demand tab, Lead Times view. Question: how stable is this lane's lead time? Read: movement dots are sized by quantity; the established forecast line and bootstrap percentiles feed MEIO Tier 0 (3.6). |
| Causal results view (Fig. 19) | Where: Causal page. Question: what drives causal demand, and what if the fleet changes? Read: fleet × usage × failure rate produces weekly demand; edit inputs and re-run for the what-if (5.4). |
| KPI / zone views (Figs. 21–22) | Where: Dashboard IO tab and MEIO scenarios. Question: where did budget go, and who reached service level? Read: segment fill-rate progress and network group are shown alongside the zone member split of the pooled envelope (6). |
Cross-references: the supply projection charts and their supersession cutover marks are documented with Point 7; the allocation overview's grids and KPIs with Point 7's allocation head; the replay dashboard's comparison views with Point 10.
5.D — For developers — the forecast-chain APIs¶
The UI paths above cover the planner's loop; the equivalents for scripts and add-ons:
| Call | Purpose |
|---|---|
POST /api/pipeline/run/forecast \| /causal \| /maintenance \| /indirect-demand \| /netting {"pipeline_id": N} |
Run the five steps standalone (CLI: python files/run_pipeline.py --only <step> --pipeline-id N). |
| The series detail endpoints | The forecast/backtest/hyperparameter surfaces the series pages render (per-series values, method explanation, single-method runs). |
5.T — Step-by-step test walkthrough¶
The forecast chain, verified per series.
| # | Where to look / what to click | You should see |
|---|---|---|
| 1 | Processes → Forecast card → Run (pipeline selected) | per-series progress streams; the step writes the PIPE_ forecast tables |
| 2 | Open a series page (/series/:uid) → Forecast tab |
the fitted forecast + confidence bands; the method dropdown stars the best method |
| 3 | Series → Outlier tab | IQR/z flags on spikes; the corrected series; corrections feed the forecast |
| 4 | Series → Netting tab | the consumption table + KPI panel: forecast consumed by firm demand, returns, approved replenishments |
| 5 | Series → Backtest / Hyperparameters tab | per-method metrics (sMAPE…); the chosen best method matches the starred dropdown |
| 6 | Causal page: fleet plan / usage grids → run the causal step | the causal forecast joins the consensus |
| 7 | Maintenance scenario: Schedule, BOM and Coverage → run Maintenance Forecast and Forecast Netting | the Maint row shows event demand; Supply Plan reflects the pipeline's Add or Net setting |

The series Forecast tab: fitted values, confidence bands, method dropdown.

The Netting tab: consumption streams + KPI panel.



