|
Run in Colab Enterprise |
Run in Colab Enterprise: click the badge to import this notebook, pick a runtime, and Run all. The Terraform-deployed templates already carry the
SF_*run identity in their env, so there's no environment cell to fill in. Runs on thesf-mainruntime template (Python 3.11). Seedocs/notebook_runtimes.mdfor the per-notebook template mapping and the headless acceptance harness.
06 · Coherent Hierarchical, Cross-Temporal (THieF) & Simplex Forecasting + Top-Down Goal-Seek QP¶
Enterprise organizations require forecasts that add up coherently across product, geography, and organizational hierarchies (__total__ $\rightarrow$ region $\rightarrow$ region/category $\rightarrow$ ts_id), across planning calendars (Daily $\rightarrow$ Weekly $\rightarrow$ Bi-Weekly $\rightarrow$ 4-Week via THieF and cross_temporal_mint), across constant-sum market-share simplexes (@transform_clr and @transform_ilr), and under executive top-down target revisions (allocate_target constrained QP). scale-forecasting implements full bottom-up aggregation, cross-sectional and cross-temporal projection $\tilde{y} = S G \hat{y}$, compositional simplex closure, and precision-weighted Goal-Seek QP across reconciliation.py, temporal_reconciliation.py, simplex.py, and goal_seek.py:
At a glance¶
| Dimension | Details |
|---|---|
| Learning outcomes | Build bottom-up summing matrices (S), execute FPP3 & cross-temporal reconciliation methods (bottom_up, top_down, middle_out, ols, wls_struct, wls_var, mint_shrink, mint_nonneg, cross_temporal_mint), run THieF temporal hierarchy reconciliation (temporal_reconcile_df), forecast constant-sum market shares with @transform_clr and @transform_ilr, and disaggregate executive targets with allocate_target() + plot_goal_seek(). |
| Prerequisites | Deployed scale-forecasting Google Cloud project (SF_* env vars) + scale-forecasting[gcp]. |
| Estimated time | ~5–8 minutes. |
| Estimated run cost | Estimated ~\$0.10–\$0.40 USD (Vertex AI / GCE / Spark / BigQuery compute for the hierarchical panel + BigQuery Storage API). |
| Ongoing cost | Zero compute when idle (ephemeral job compute tears down automatically on completion). |
| Method | Formula / Weighting | When to Use |
|---|---|---|
bottom_up |
Sums bottom-level forecasts directly ($G = [0 \mid I]$) | High signal-to-noise bottom series; zero aggregate model bias |
top_down |
Disaggregates __total__ forecast by historical average proportions $p_i$ |
Noisy bottom series with stable macro proportions |
middle_out |
Anchors at an intermediate middle_level, sums up & disaggregates down |
Strong regional/category signal |
ols |
Identity error covariance ($W = I$) ordinary least squares projection | Fast coherence without backtest residuals |
wls_struct |
Structural variance scaling ($W = \text{diag}(S \mathbf{1})$) | Balanced accuracy across hierarchy levels without OOF residuals |
wls_var |
Diagonal out-of-fold residual variance ($W = \text{diag}(\hat{\sigma}_i^2)$) | Heteroskedastic series with backtesting enabled |
mint_shrink |
Schafer-Strimmer shrinkage covariance of OOF residuals ($W = \hat{\Sigma}_{\text{shrink}}$) | Gold standard — exploits cross-series error correlations |
mint_nonneg |
Active-set non-negative Minimum Trace QP ($\tilde{b}_t \ge 0$) | Guarantees non-negative reconciled SKU forecasts |
cross_temporal_mint |
Simultaneous cross-sectional ($S_{\text{cs}}$) & temporal ($S_{\text{temp}}$) MinT | Coherent across both the hierarchy tree and calendar buckets ([7, 14, 28]) |
Act 1 · Cloud Bootstrap & Deployment Resolution¶
On a managed cloud notebook (Colab Enterprise, Vertex AI Workbench) the bootstrap cell below clones or updates the repository and installs the locked dependency set (uv.lock) into an isolated .colab-deps prefix so import scale_forecasting resolves against the exact package versions every cloud worker uses. In a local clone with .venv, this cell is a fast no-op.
# Cloud bootstrap: clone + install the LOCKED dependency set (uv.lock) so
# `import scale_forecasting` resolves against the exact versions every other surface runs.
import importlib.util
import os
import shutil
import subprocess
import sys
REPO_URL = os.environ.get("SF_REPO_URL", "https://github.com/statmike/scale-forecasting.git")
REPO_DIR = os.environ.get("SF_REPO_DIR", "scale-forecasting")
EXTRAS = ['gcp']
if importlib.util.find_spec("scale_forecasting") is None:
if not os.path.isdir(REPO_DIR):
subprocess.run(["git", "clone", "--depth", "1", REPO_URL, REPO_DIR], check=True)
uv = shutil.which("uv")
if uv is None:
subprocess.run([sys.executable, "-m", "pip", "install", "-q", "uv"], check=True)
uv = shutil.which("uv") or "uv"
reqs = os.path.abspath(os.path.join(REPO_DIR, "colab-requirements.txt"))
extra_flags = [f for e in EXTRAS for f in ("--extra", e)]
subprocess.run(
[uv, "export", "--frozen", "--no-emit-project", "--no-hashes", "--no-dev", *extra_flags, "-o", reqs],
cwd=REPO_DIR,
check=True,
)
target = os.path.abspath(os.path.join(REPO_DIR, ".colab-deps"))
subprocess.run(
[uv, "pip", "install", "--python", sys.executable, "--target", target, "-r", reqs],
check=True,
)
sys.path.insert(0, target)
sys.path.insert(0, os.path.join(REPO_DIR, "src"))
print("installed scale_forecasting from", REPO_DIR)
else:
print("scale_forecasting already importable — skipping bootstrap")
scale_forecasting already importable — skipping bootstrap
Resolve the Live GCP Deployment (Settings.resolve())¶
Settings.resolve() reads the SF_* environment variables (SF_PROJECT_ID, SF_REGION, SF_DATASET_ID, SF_WAREHOUSE_URI, SF_CONNECTION, SF_COMPUTE_SA) pre-populated by Terraform in the sf-main runtime template (or your local shell).
from google.cloud import bigquery
from scale_forecasting.settings import Settings
settings = Settings.resolve()
client = bigquery.Client(project=settings.project_id)
DATASET = settings.dataset_ref
print(f"Deployment: {DATASET} | Region: {settings.region} | Bucket: {settings.warehouse_uri}")
Deployment: statmike-scale-forecasting.scale_forecasting | Region: us-central1 | Bucket: gs://statmike-scale-forecasting-warehouse/warehouse
Act 2 · Configure Hierarchical Forecasting & Explain the Plan¶
We configure hierarchy={'enabled': True, 'levels': [['region'], ['region', 'category']], 'reconciliation_methods': ['bottom_up', 'wls_struct', 'mint_shrink']} so the engine automatically rolls up the panel before model fitting and reconciles both out-of-fold backtest predictions and future forecasts.
import time
from scale_forecasting import Forecaster, RunConfig
# === Parameters — edit me ===============================================
RUN_NAME = f"nb06 hierarchy mint {int(time.time())}"
SOURCE_TABLE = "source_series_covariates_native" # includes region & category hierarchy columns
MODELS = ["theta", "holtwinters", "lightgbm"]
RECON_METHODS = ["bottom_up", "wls_struct", "mint_shrink"]
HORIZON = 14
SERIES_LIMIT = 20
# ========================================================================
cfg = RunConfig(
run_name=RUN_NAME,
python_runtime="vertex",
data={"source_table": SOURCE_TABLE, "horizon": HORIZON, "series_limit": SERIES_LIMIT},
models=MODELS,
hierarchy={
"enabled": True,
"levels": [["region"], ["region", "category"]],
"reconciliation_methods": RECON_METHODS,
},
backtest={"enabled": True, "n_folds": 2, "horizon": HORIZON, "step": HORIZON},
ensemble={"enabled": True, "strategies": ["inverse_error", "nnls"]},
)
forecaster = Forecaster(cfg, settings=settings)
print("run_id:", forecaster.run_id)
display(forecaster.explain(validate_data=False))
run_id: nb06-hierarchy-mint-1791145253-bbc069a2c659
| run_id | family | job_key | runtime | machine_type | workers | hardware | gpu_type | models | training_modes | n_series | n_folds | expected_cells | covariates | depends_on | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | nb06-hierarchy-mint-1791145253-bbc069a2c659 | statistical | sf-nb06-hierarchy-mint-1791145253-bbc069a2c659... | vertex | n2-standard-8 | 1 | cpu | None | theta, holtwinters | theta:local, holtwinters:local | 20 | 2 | 40 | none | |
| 1 | nb06-hierarchy-mint-1791145253-bbc069a2c659 | ml | sf-nb06-hierarchy-mint-1791145253-bbc069a2c659... | vertex | n2-standard-8 | 1 | cpu | None | lightgbm | lightgbm:local | 20 | 2 | 20 | none | |
| 2 | nb06-hierarchy-mint-1791145253-bbc069a2c659 | ensemble | sf-nb06-hierarchy-mint-1791145253-bbc069a2c659... | bigquery | sql | 1 | sql | None | ensemble_inverse_error, ensemble_nnls | barrier | 20 | 2 | 40 | none | sf-nb06-hierarchy-mint-1791145253-bbc069a2c659... |
Act 3 · Launch & Monitor Live (forecaster.run_live())¶
During execution, the worker engine augments the 20 bottom series with their aggregate parent nodes (__total__, region=*, region=*/category=*), fits each model, reconciles every model's forecasts across bottom_up, wls_struct, and mint_shrink, and writes the coherent forecasts to BigQuery.
result = forecaster.run_live(poll_s=15.0, probe=True)
print(f"Completed {result.run_id}: status={result.status}, runtime={result.runtime_seconds:.1f}s")
Completed nb06-hierarchy-mint-1791145253-bbc069a2c659: status=COMPLETED, runtime=427.4s
Act 4 · Inspect Hierarchy Level Rollups (hierarchy_df & plot_hierarchy)¶
forecaster.hierarchy_df() and forecaster.plot_hierarchy() aggregate predicted totals across each level of the tree (level_0_total, level_1, level_2, bottom_or_leaf) to verify that every level sums to the exact same grand total.
import matplotlib.pyplot as plt
from scale_forecasting import plot_leaderboard
display(forecaster.leaderboard_df())
plot_leaderboard(forecaster.review_run())
plt.show()
h_df = forecaster.hierarchy_df()
display(h_df)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(13, 4.5))
forecaster.plot_hierarchy(model_type="theta", ax=ax1, title="Before Reconciliation")
forecaster.plot_hierarchy(model_type="theta_mint_shrink", ax=ax2, title="After MinT Shrinkage")
fig.tight_layout()
plt.show()
| rank | model_type | family | is_ensemble | ensemble_id | compute_engine | n_series | decision_metric | score | pooled_wape | ... | mean_mae | mean_rmse | mean_coverage | mean_interval_score | mean_fit_seconds | median_fit_seconds | no_artifact_rate | n_predictions | lift_vs_best_base | lift_pct | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | holtwinters_mint_shrink | unknown | False | None | vertex | 37 | wape | 0.290296 | 0.101042 | ... | 19.777619 | 29.661252 | 0.686293 | 112.278367 | 1.656038 | 1.460099 | 1.0 | 518 | NaN | NaN |
| 1 | 2 | holtwinters_bottom_up | unknown | False | None | vertex | 37 | wape | 0.300555 | 0.103318 | ... | 21.299447 | 31.538323 | 0.622587 | 118.562089 | 1.656038 | 1.460099 | 1.0 | 518 | NaN | NaN |
| 2 | 3 | holtwinters | statistical | False | None | vertex | 37 | wape | 0.302522 | 0.100471 | ... | 21.196424 | 28.973053 | 0.666023 | 108.865936 | 1.656038 | 1.460099 | 1.0 | 518 | NaN | NaN |
| 3 | 4 | lightgbm_mint_shrink | unknown | False | None | vertex | 37 | wape | 0.305898 | 0.092156 | ... | 17.987551 | 26.310532 | 0.277992 | 137.620348 | 1.015369 | 0.821361 | 1.0 | 518 | NaN | NaN |
| 4 | 5 | ensemble_inverse_error | ensemble | True | 34432fdde9fa | ensemble | 37 | wape | 0.306834 | 0.095035 | ... | 19.474818 | 27.197892 | NaN | NaN | NaN | NaN | 1.0 | 518 | -0.016538 | -0.056969 |
| 5 | 6 | holtwinters_wls_struct | unknown | False | None | vertex | 37 | wape | 0.312112 | 0.097846 | ... | 20.821935 | 31.072354 | 0.596525 | 128.089127 | 1.656038 | 1.460099 | 1.0 | 518 | NaN | NaN |
| 6 | 7 | theta_mint_shrink | unknown | False | None | vertex | 37 | wape | 0.322315 | 0.109499 | ... | 21.620279 | 31.275288 | 0.989382 | 234.936310 | 1.899232 | 1.767336 | 1.0 | 518 | NaN | NaN |
| 7 | 8 | ensemble_nnls | ensemble | True | 34432fdde9fa | ensemble | 37 | wape | 0.325074 | 0.097184 | ... | 20.193194 | 27.936101 | NaN | NaN | NaN | NaN | 0.0 | 518 | -0.034778 | -0.119801 |
| 8 | 9 | lightgbm_bottom_up | unknown | False | None | vertex | 37 | wape | 0.331109 | 0.099090 | ... | 19.987410 | 28.746893 | 0.302124 | 144.084096 | 1.015369 | 0.821361 | 1.0 | 518 | NaN | NaN |
| 9 | 10 | theta_bottom_up | unknown | False | None | vertex | 37 | wape | 0.332475 | 0.110100 | ... | 22.993494 | 33.070271 | 0.991313 | 248.964410 | 1.899232 | 1.767336 | 1.0 | 518 | NaN | NaN |
| 10 | 11 | lightgbm | ml | False | None | vertex | 37 | wape | 0.342224 | 0.103643 | ... | 21.298468 | 29.281147 | 0.302124 | 152.355357 | 1.015369 | 0.821361 | 1.0 | 518 | NaN | NaN |
| 11 | 12 | theta_wls_struct | unknown | False | None | vertex | 37 | wape | 0.344228 | 0.105001 | ... | 22.186364 | 32.193439 | 0.977799 | 203.129876 | 1.899232 | 1.767336 | 1.0 | 518 | NaN | NaN |
| 12 | 13 | theta | statistical | False | None | vertex | 37 | wape | 0.344728 | 0.106097 | ... | 22.334919 | 30.012708 | 0.992278 | 293.876694 | 1.899232 | 1.767336 | 1.0 | 518 | NaN | NaN |
| 13 | 14 | lightgbm_wls_struct | unknown | False | None | vertex | 37 | wape | 0.430991 | 0.096712 | ... | 19.718478 | 28.989593 | 0.281853 | 155.450679 | 1.015369 | 0.821361 | 1.0 | 518 | NaN | NaN |
14 rows × 25 columns
| model_type | level | n_series | n_points | mean_yhat | sum_yhat | max_coherence_residual | |
|---|---|---|---|---|---|---|---|
| 0 | ensemble_inverse_error | total | 1 | 14 | 2041.509304 | 28581.130250 | 1.720098e+02 |
| 1 | ensemble_inverse_error | aggregate | 16 | 224 | 254.698593 | 57052.484804 | 1.720098e+02 |
| 2 | ensemble_inverse_error | bottom | 20 | 280 | 98.526903 | 27587.532735 | 1.720098e+02 |
| 3 | ensemble_nnls | total | 1 | 14 | 2033.259359 | 28465.631027 | 1.556478e+02 |
| 4 | ensemble_nnls | aggregate | 16 | 224 | 257.158405 | 57603.482652 | 1.556478e+02 |
| 5 | ensemble_nnls | bottom | 20 | 280 | 100.847734 | 28237.365411 | 1.556478e+02 |
| 6 | holtwinters | total | 1 | 14 | 2055.259926 | 28773.638965 | 1.677141e+02 |
| 7 | holtwinters | aggregate | 16 | 224 | 251.861556 | 56416.988558 | 1.677141e+02 |
| 8 | holtwinters | bottom | 20 | 280 | 95.761727 | 26813.283446 | 1.677141e+02 |
| 9 | holtwinters_bottom_up | total | 1 | 14 | 1915.234532 | 26813.283446 | 2.273737e-13 |
| 10 | holtwinters_bottom_up | aggregate | 16 | 224 | 239.404316 | 53626.566892 | 2.273737e-13 |
| 11 | holtwinters_bottom_up | bottom | 20 | 280 | 95.761727 | 26813.283446 | 2.273737e-13 |
| 12 | holtwinters_mint_shrink | total | 1 | 14 | 1978.191835 | 27694.685693 | 4.547474e-13 |
| 13 | holtwinters_mint_shrink | aggregate | 16 | 224 | 247.273979 | 55389.371386 | 4.547474e-13 |
| 14 | holtwinters_mint_shrink | bottom | 20 | 280 | 98.909592 | 27694.685693 | 4.547474e-13 |
| 15 | holtwinters_wls_struct | total | 1 | 14 | 2000.069839 | 28000.977742 | 4.547474e-13 |
| 16 | holtwinters_wls_struct | aggregate | 16 | 224 | 250.008730 | 56001.955484 | 4.547474e-13 |
| 17 | holtwinters_wls_struct | bottom | 20 | 280 | 100.003492 | 28000.977742 | 4.547474e-13 |
| 18 | lightgbm | total | 1 | 14 | 2020.503921 | 28287.054896 | 2.735230e+02 |
| 19 | lightgbm | aggregate | 16 | 224 | 260.400024 | 58329.605338 | 2.735230e+02 |
| 20 | lightgbm | bottom | 20 | 280 | 103.702852 | 29036.798615 | 2.735230e+02 |
| 21 | lightgbm_bottom_up | total | 1 | 14 | 2074.057044 | 29036.798615 | 4.547474e-13 |
| 22 | lightgbm_bottom_up | aggregate | 16 | 224 | 259.257130 | 58073.597229 | 4.547474e-13 |
| 23 | lightgbm_bottom_up | bottom | 20 | 280 | 103.702852 | 29036.798615 | 4.547474e-13 |
| 24 | lightgbm_mint_shrink | total | 1 | 14 | 2057.980161 | 28811.722248 | 4.547474e-13 |
| 25 | lightgbm_mint_shrink | aggregate | 16 | 224 | 257.247520 | 57623.444495 | 4.547474e-13 |
| 26 | lightgbm_mint_shrink | bottom | 20 | 280 | 102.899008 | 28811.722248 | 4.547474e-13 |
| 27 | lightgbm_wls_struct | total | 1 | 14 | 2065.240337 | 28913.364712 | 9.094947e-13 |
| 28 | lightgbm_wls_struct | aggregate | 16 | 224 | 258.155042 | 57826.729424 | 9.094947e-13 |
| 29 | lightgbm_wls_struct | bottom | 20 | 280 | 103.262017 | 28913.364712 | 9.094947e-13 |
| 30 | theta | total | 1 | 14 | 2049.633483 | 28694.868758 | 1.528919e+02 |
| 31 | theta | aggregate | 16 | 224 | 252.896365 | 56648.785670 | 1.528919e+02 |
| 32 | theta | bottom | 20 | 280 | 97.237932 | 27226.620901 | 1.528919e+02 |
| 33 | theta_bottom_up | total | 1 | 14 | 1944.758636 | 27226.620901 | 4.547474e-13 |
| 34 | theta_bottom_up | aggregate | 16 | 224 | 243.094829 | 54453.241802 | 4.547474e-13 |
| 35 | theta_bottom_up | bottom | 20 | 280 | 97.237932 | 27226.620901 | 4.547474e-13 |
| 36 | theta_mint_shrink | total | 1 | 14 | 2015.972547 | 28223.615657 | 4.547474e-13 |
| 37 | theta_mint_shrink | aggregate | 16 | 224 | 251.996568 | 56447.231314 | 4.547474e-13 |
| 38 | theta_mint_shrink | bottom | 20 | 280 | 100.798627 | 28223.615657 | 4.547474e-13 |
| 39 | theta_wls_struct | total | 1 | 14 | 2010.183488 | 28142.568832 | 9.094947e-13 |
| 40 | theta_wls_struct | aggregate | 16 | 224 | 251.272936 | 56285.137664 | 9.094947e-13 |
| 41 | theta_wls_struct | bottom | 20 | 280 | 100.509174 | 28142.568832 | 9.094947e-13 |
Act 5 · Three-Mode Reconciliation (Spatial-Only, Temporal-Only & Cross-Temporal with spatial_temporal_weight="auto") + Coherent Sample Paths (sample_coherent_paths)¶
HierarchyConfig supports three orthogonal reconciliation regimes:
- Mode 1 — Spatial-Only (
reconcile_temporal=False): Reconciles strictly across the organizational tree ($\mathbf{S}_{\text{cs}}$,spatial_weight_alpha = 1.0). - Mode 2 — Temporal-Only (
THieFon a flat panel,levels=[],reconcile_temporal=True): Reconciles each series across calendar aggregation buckets ($\mathbf{S}_{\text{temp}}$,spatial_weight_alpha = 0.0) on both forward predictions and rolling-origin OOF folds. - Mode 3 — Joint Cross-Temporal (
cross_temporal=True,spatial_temporal_weight="auto"): Keeps pure spatial methods (<model>_mint_shrink,<model>_wls_struct) on the leaderboard alongside<model>_cross_temporal_mint, learns the OOF-optimal $\alpha^* \in [0, 1]$ balancing spatial and temporal projections, and refines via alternating projections to $< 10^{-6}$ discrepancy on both axes simultaneously. We also simulate $N=50$ joint trajectories viaforecaster.sample_coherent_paths(n_paths=50):
from scale_forecasting import (
reconcile_forecasts,
reconcile_temporal_forecasts,
verify_coherence,
verify_cross_temporal_coherence,
verify_temporal_coherence,
)
# 1. Reconcile persisted run predictions across Mode 3 (cross_temporal_mint with spatial_temporal_weight="auto")
ct_df, coarse_aggs = forecaster.temporal_reconcile_df(
method="cross_temporal_mint",
model_type="theta",
temporal_aggregations=[7, 14],
return_aggregations=True,
)
hier_spec = ct_df.attrs["hierarchy_spec"]
ct_diag = ct_df.attrs.get("cross_temporal_diagnostics", {})
# Compare Mode 1 (Spatial-Only) and Mode 2 (Temporal-Only on root series) diagnostics
sp_only_df = reconcile_forecasts(
ct_df[["ts_id", "model_type", "forecast_date", "yhat", "yhat_lower", "yhat_upper"]],
hier_spec,
method="mint_shrink",
date_col="forecast_date",
)
tm_only_df = reconcile_temporal_forecasts(
ct_df[ct_df["ts_id"] == "__total__"][
["ts_id", "model_type", "forecast_date", "yhat", "yhat_lower", "yhat_upper"]
],
method="wls_struct",
aggregations=[7, 14],
)
cs_disc = verify_coherence(ct_df, hier_spec)
temp_disc = verify_temporal_coherence(ct_df, coarse_aggs)
ct_disc = verify_cross_temporal_coherence(ct_df, hier_spec, coarse_aggs)
print(
f"Mode 1 (Spatial-Only): mode={sp_only_df.attrs['cross_temporal_diagnostics']['mode']}, "
f"alpha={sp_only_df.attrs['cross_temporal_diagnostics']['spatial_weight_alpha']:.2f}\n"
f"Mode 2 (Temporal-Only): mode={tm_only_df.attrs['cross_temporal_diagnostics']['mode']}, "
f"alpha={tm_only_df.attrs['cross_temporal_diagnostics']['spatial_weight_alpha']:.2f}, "
f"temp_disc={tm_only_df.attrs['cross_temporal_diagnostics']['final_temp_discrepancy']:.2e}\n"
f"Mode 3 (Cross-Temporal): mode={ct_diag.get('mode')}, "
f"alpha={ct_diag.get('spatial_weight_alpha', 0.5):.3f}, "
f"cs_disc={cs_disc:.2e}, temp_disc={temp_disc:.2e}, joint_disc={ct_disc:.2e}"
)
# 2. Simulate 50 coherent cross-temporal sample paths (< 1e-6 discrepancy on every path_id)
paths_df = forecaster.sample_coherent_paths(forecasts_df=ct_df, n_paths=50, seed=42)
max_path_cs = max(verify_coherence(g, hier_spec) for _, g in paths_df.groupby("path_id"))
print(
f"Simulated {paths_df['path_id'].nunique()} coherent trajectories ({len(paths_df)} rows): "
f"max cross-sectional discrepancy across all paths = {max_path_cs:.2e}"
)
display(ct_df.head(6))
Mode 1 (Spatial-Only): mode=spatial_only, alpha=1.00 Mode 2 (Temporal-Only): mode=temporal_only, alpha=0.00, temp_disc=3.64e-12 Mode 3 (Cross-Temporal): mode=cross_temporal, alpha=0.123, cs_disc=4.55e-13, temp_disc=0.00e+00, joint_disc=4.55e-13
Simulated 50 coherent trajectories (25900 rows): max cross-sectional discrepancy across all paths = 1.36e-12
| ts_id | model_type | ensemble_id | compute_engine | forecast_date | yhat | yhat_lower | yhat_upper | explanations | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | __total__ | theta | None | vertex | 2024-12-31 | 1790.214555 | 1724.098453 | 1856.330656 | null |
| 1 | region=APAC | theta | None | vertex | 2024-12-31 | 389.658816 | 367.984233 | 411.333400 | null |
| 2 | region=EMEA | theta | None | vertex | 2024-12-31 | 461.922621 | 430.912265 | 492.932977 | null |
| 3 | region=LATAM | theta | None | vertex | 2024-12-31 | 535.651435 | 513.547707 | 557.755163 | null |
| 4 | region=NA | theta | None | vertex | 2024-12-31 | 402.981682 | 348.615089 | 457.348276 | null |
| 5 | region=APAC/category=SMB | theta | None | vertex | 2024-12-31 | 69.129108 | 55.167593 | 83.090623 | null |
Act 6 · Compositional Simplex (verify_simplex), Smooth Multi-Period Goal-Seek QP (smoothness_weight) & Practitioner Assessment (f.assess())¶
In addition to 3-mode reconciliation and coherent path simulation, scale-forecasting provides:
- Compositional Simplex Transforms (
@transform_clr&@transform_ilr): Forecasts market-share percentages or category-mix proportions using Aitchison Centered Log-Ratio (clr) and Isometric Log-Ratio (ilrHelmert contrast matrix) coordinates so predictions stay strictly inside $(0, S)$ and sum to $S = 100.0\%$ at every horizon date (forecast_simplex_panel(),verify_simplex()). - Smooth Multi-Period Top-Down Goal-Seek Constrained QP (
forecaster.allocate_target(..., smoothness_weight=10.0)&forecaster.plot_goal_seek()): Disaggregates an executive top-down target across leaf series and dates using precision-weighted Minimum-Trace Quadratic Programming with $\ell_2$ first-difference roughness penalty (smoothness_weight) while honoringlocked_nodes, box[lower_bounds, upper_bounds], and propagating gross margin (gross_margin_delta) and inventory replenishment impacts (delta_reorder_point,delta_safety_stock). - 7-Question Practitioner Assessment (
f.assess()/f.practitioner_assessment_df()): Surfaces causal guardrails in Question 3 and active reconciliation mode + simplex closure in Question 5.
import numpy as np
import warnings
from scale_forecasting import (
close_simplex,
forecast_simplex_panel,
summarize_goal_seek,
verify_simplex,
)
warnings.filterwarnings("ignore")
# 1. Compositional Market-Share Simplex Forecasting (@transform_ilr & @transform_clr, S = 100.0%)
_, _, live_hist_df = forecaster._resolve_track_k_frames()
top4_ids = sorted(live_hist_df["ts_id"].unique())[:4]
simplex_panel = close_simplex(
live_hist_df[live_hist_df["ts_id"].isin(top4_ids)][["ts_id", "ds", "y"]],
value_col="y",
simplex_sum=100.0,
)
ilr_preds = forecast_simplex_panel(
simplex_panel,
model_name="theta@transform_ilr",
transform="ilr",
horizon=HORIZON,
simplex_sum=100.0,
)
clr_preds = forecast_simplex_panel(
simplex_panel,
model_name="holtwinters@transform_clr",
transform="clr",
horizon=HORIZON,
simplex_sum=100.0,
)
ilr_err = verify_simplex(ilr_preds, simplex_sum=100.0)
clr_err = verify_simplex(clr_preds, simplex_sum=100.0)
print(
f"Compositional simplex coherence (S=100.0%): "
f"theta@transform_ilr max_err={ilr_err:.2e}, "
f"holtwinters@transform_clr max_err={clr_err:.2e}"
)
display(
ilr_preds.groupby("ds", as_index=False)["yhat"]
.sum()
.rename(columns={"yhat": "total_market_share_pct"})
.head(6)
)
# 2. Smooth Multi-Period Top-Down Goal-Seek Constrained QP (smoothness_weight=10.0 vs 0.0)
root_baseline = float(ct_df[ct_df["ts_id"] == "__total__"]["yhat"].sum())
bottom_ids = list(ct_df.attrs["hierarchy_spec"].bottom_ids)
locked_leaf = bottom_ids[0]
goal_seek_unsmoothed = forecaster.allocate_target(
target_total=root_baseline * 1.15,
forecasts_df=ct_df,
locked_nodes=[locked_leaf],
floor=0.0,
cap=10000.0,
smoothness_weight=0.0,
)
goal_seek_df = forecaster.allocate_target(
target_total=root_baseline * 1.15,
forecasts_df=ct_df,
locked_nodes=[locked_leaf],
floor=0.0,
cap=10000.0,
smoothness_weight=10.0,
prices=25.0,
unit_cost=15.0,
include_inventory_impact=True,
)
def _step_roughness(df_alloc):
sub = df_alloc[df_alloc["ts_id"].isin(bottom_ids)].sort_values(["ts_id", "ds"])
total = 0.0
for _, grp in sub.groupby("ts_id"):
delta = grp["allocated_yhat"].to_numpy(float) - grp["baseline_yhat"].to_numpy(float)
total += float(np.sum(np.diff(delta) ** 2))
return total
print(
f"Goal-Seek temporal step roughness: smoothness_weight=0.0 -> {_step_roughness(goal_seek_unsmoothed):.4f}, "
f"smoothness_weight=10.0 -> {_step_roughness(goal_seek_df):.4f}"
)
display(summarize_goal_seek(goal_seek_df))
display(
goal_seek_df[goal_seek_df["ts_id"].isin(["__total__", locked_leaf, bottom_ids[1]])][
[
"ts_id",
"ds",
"baseline_yhat",
"allocated_yhat",
"delta_units",
"delta_pct",
"constraint_status",
"gross_margin_delta",
"delta_reorder_point",
]
].head(8)
)
# 3. 7-Question Practitioner Assessment on Compositional Simplex Panel (f.assess())
f_sim_auto = Forecaster.auto(
simplex_panel,
horizon=7,
freq="D",
models=["naive_mean@transform_ilr", "theta@transform_clr"],
baselines=["naive_mean"],
hpo=False,
calibration=False,
explainability=False,
n_folds=1,
autofocus=False,
)
display(
f_sim_auto.practitioner_assessment_df()[
["question_id", "verdict", "answer", "evidence", "recommendation"]
]
)
forecaster.plot_goal_seek(
goal_seek_df,
top_n=6,
title="Smooth Top-Down Goal-Seek QP (+15% Grand Total Target, smoothness_weight=10.0)",
)
plt.show()
# 4. Simplex Pre-Pack Allocation, Assortment Rationalization & Lateral Store Rebalancing (Track Q.2 / R.2)
as_06 = forecaster.optimize_assortment(max_skus=4)
pp_06 = forecaster.optimize_prepacks(sizes=["S", "M", "L", "XL"], pack_size=6)
rb_06 = forecaster.optimize_rebalancing(safety_stock="auto")
print(
f"Assortment Rationalization (Track Q.2): Retained {as_06.retained_skus}/{as_06.total_candidate_skus} SKUs | "
f"Transferred: {as_06.transferred_units:,.1f}u | Category Retention: {as_06.category_retention_pct:.1%}"
)
print(
f"Integer Pre-Pack MILP (Track R.2): {pp_06.total_allocated_units:,.0f}u allocated | "
f"Fill Rate: {pp_06.fill_rate_pct:.1%} | Overstock: {pp_06.total_overstock_units:,.1f}u"
)
print(
f"Lateral Store Rebalancing (Track R.2): Transferred {rb_06.total_transferred_units:,.1f}u | "
f"Net Cost Savings: +${rb_06.net_cost_savings:,.2f}"
)
Compositional simplex coherence (S=100.0%): theta@transform_ilr max_err=2.84e-14, holtwinters@transform_clr max_err=1.42e-14
| ds | total_market_share_pct | |
|---|---|---|
| 0 | 2024-12-31 | 100.0 |
| 1 | 2025-01-01 | 100.0 |
| 2 | 2025-01-02 | 100.0 |
| 3 | 2025-01-03 | 100.0 |
| 4 | 2025-01-04 | 100.0 |
| 5 | 2025-01-05 | 100.0 |
Goal-Seek temporal step roughness: smoothness_weight=0.0 -> 27889.6763, smoothness_weight=10.0 -> 15.7441
| ts_id | model_type | baseline_total_units | allocated_total_units | y_allocated_sum | baseline_yhat | allocated_yhat | delta_units | delta_yhat | delta_pct | ... | delta_gross_margin | baseline_reorder_point | allocated_reorder_point | delta_reorder_point | baseline_safety_stock | allocated_safety_stock | delta_safety_stock | baseline_order_qty | allocated_order_qty | delta_order_qty | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | __total__ | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 14266.302170 | 16329.139321 | 2062.837151 | 402.243361 | 402.243361 | 5.684342e-14 | 14266.302170 | 16329.139321 | 2062.837151 |
| 1 | region=APAC | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 13994.134964 | 16056.972114 | 2062.837151 | 130.076154 | 130.076154 | 0.000000e+00 | 13994.134964 | 16056.972114 | 2062.837151 |
| 2 | region=EMEA | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 14055.828046 | 16118.665197 | 2062.837151 | 191.769237 | 191.769237 | 5.684342e-14 | 14055.828046 | 16118.665197 | 2062.837151 |
| 3 | region=LATAM | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 14006.871116 | 16069.708267 | 2062.837151 | 142.812307 | 142.812307 | 0.000000e+00 | 14006.871116 | 16069.708267 | 2062.837151 |
| 4 | region=NA | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 14130.474280 | 16193.311431 | 2062.837151 | 266.415471 | 266.415471 | 0.000000e+00 | 14130.474280 | 16193.311431 | 2062.837151 |
| 5 | region=APAC/category=SMB | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 13946.257875 | 16009.095026 | 2062.837151 | 82.199066 | 82.199066 | 0.000000e+00 | 13946.257875 | 16009.095026 | 2062.837151 |
| 6 | region=APAC/category=consumer | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 13905.425553 | 15968.262704 | 2062.837151 | 41.366744 | 41.366744 | 0.000000e+00 | 13905.425553 | 15968.262704 | 2062.837151 |
| 7 | region=APAC/category=enterprise | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 13952.665171 | 16015.502322 | 2062.837151 | 88.606362 | 88.606362 | 0.000000e+00 | 13952.665171 | 16015.502322 | 2062.837151 |
| 8 | region=EMEA/category=SMB | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 13939.259257 | 16002.096408 | 2062.837151 | 75.200448 | 75.200448 | 0.000000e+00 | 13939.259257 | 16002.096408 | 2062.837151 |
| 9 | region=EMEA/category=consumer | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 14017.288806 | 16080.125957 | 2062.837151 | 153.229997 | 153.229997 | 0.000000e+00 | 14017.288806 | 16080.125957 | 2062.837151 |
| 10 | region=EMEA/category=enterprise | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 13971.033752 | 16033.870903 | 2062.837151 | 106.974943 | 106.974943 | 0.000000e+00 | 13971.033752 | 16033.870903 | 2062.837151 |
| 11 | region=LATAM/category=SMB | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 13991.684766 | 16054.521917 | 2062.837151 | 127.625957 | 127.625957 | 0.000000e+00 | 13991.684766 | 16054.521917 | 2062.837151 |
| 12 | region=LATAM/category=consumer | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 13882.044379 | 15944.881529 | 2062.837151 | 17.985569 | 17.985569 | 0.000000e+00 | 13882.044379 | 15944.881529 | 2062.837151 |
| 13 | region=LATAM/category=enterprise | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 13958.609697 | 16021.446848 | 2062.837151 | 94.550887 | 94.550887 | 0.000000e+00 | 13958.609697 | 16021.446848 | 2062.837151 |
| 14 | region=NA/category=SMB | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 14105.383310 | 16168.220461 | 2062.837151 | 241.324501 | 241.324501 | 0.000000e+00 | 14105.383310 | 16168.220461 | 2062.837151 |
| 15 | region=NA/category=consumer | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 14024.724530 | 16087.561681 | 2062.837151 | 160.665721 | 160.665721 | 0.000000e+00 | 14024.724530 | 16087.561681 | 2062.837151 |
| 16 | region=NA/category=enterprise | theta | 28313.204982 | 32560.185729 | 32560.185729 | 28313.204982 | 32560.185729 | 4246.980747 | 4246.980747 | 15.000000 | ... | 42469.807473 | 14019.459607 | 16082.296757 | 2062.837151 | 155.400797 | 155.400797 | 0.000000e+00 | 14019.459607 | 16082.296757 | 2062.837151 |
| 17 | s_000000 | theta | 3519.246481 | 3519.246481 | 3519.246481 | 3519.246481 | 3519.246481 | 0.000000 | 0.000000 | 0.000000 | ... | 0.000000 | 1940.812669 | 1940.812669 | 0.000000 | 222.609655 | 222.609655 | 0.000000e+00 | 1940.812669 | 1940.812669 | 0.000000 |
| 18 | s_000001 | theta | 35.146277 | 40.815652 | 40.815652 | 35.146277 | 40.815652 | 5.669375 | 5.669375 | 16.130797 | ... | 56.693748 | 30.944662 | 34.801769 | 3.857106 | 13.406040 | 14.741846 | 1.335806e+00 | 30.944662 | 34.801769 | 3.857106 |
| 19 | s_000002 | theta | 2468.477991 | 2615.543317 | 2615.543317 | 2468.477991 | 2615.543317 | 147.065326 | 147.065326 | 5.957733 | ... | 1470.653263 | 1296.523991 | 1364.586731 | 68.062741 | 66.066844 | 66.066844 | 0.000000e+00 | 1296.523991 | 1364.586731 | 68.062741 |
| 20 | s_000003 | theta | 981.770590 | 1081.151671 | 1081.151671 | 981.770590 | 1081.151671 | 99.381081 | 99.381081 | 10.122638 | ... | 993.810813 | 546.165391 | 589.359656 | 43.194265 | 56.331106 | 56.331106 | 1.421085e-14 | 546.165391 | 589.359656 | 43.194265 |
| 21 | s_000004 | theta | 596.808096 | 1559.967919 | 1559.967919 | 596.808096 | 1559.967919 | 963.159823 | 963.159823 | 161.385180 | ... | 9631.598229 | 548.159842 | 1036.013442 | 487.853600 | 242.163015 | 242.163015 | 0.000000e+00 | 548.159842 | 1036.013442 | 487.853600 |
| 22 | s_000005 | theta | 3131.867685 | 3319.883119 | 3319.883119 | 3131.867685 | 3319.883119 | 188.015434 | 188.015434 | 6.003301 | ... | 1880.154340 | 1656.578590 | 1744.789414 | 88.210824 | 77.995237 | 77.995237 | 0.000000e+00 | 1656.578590 | 1744.789414 | 88.210824 |
| 23 | s_000006 | theta | 22.016767 | 24.791725 | 24.791725 | 22.016767 | 24.791725 | 2.774958 | 2.774958 | 12.603840 | ... | 27.749581 | 23.330642 | 28.464642 | 5.134000 | 11.484716 | 14.603922 | 3.119206e+00 | 23.330642 | 28.464642 | 5.134000 |
| 24 | s_000007 | theta | 3488.902808 | 3846.738731 | 3846.738731 | 3488.902808 | 3846.738731 | 357.835923 | 357.835923 | 10.256403 | ... | 3578.359234 | 1847.943100 | 2025.849781 | 177.906681 | 119.992922 | 119.992922 | -2.842171e-14 | 1847.943100 | 2025.849781 | 177.906681 |
| 25 | s_000008 | theta | 668.125437 | 906.783803 | 906.783803 | 668.125437 | 906.783803 | 238.658366 | 238.658366 | 35.720593 | ... | 2386.583660 | 491.902507 | 623.171025 | 131.268519 | 160.665721 | 160.665721 | -2.842171e-14 | 491.902507 | 623.171025 | 131.268519 |
| 26 | s_000009 | theta | 1403.455816 | 2050.920277 | 2050.920277 | 1403.455816 | 2050.920277 | 647.464461 | 647.464461 | 46.133584 | ... | 6474.644609 | 696.723730 | 1012.717540 | 315.993809 | 153.229997 | 153.229997 | 0.000000e+00 | 696.723730 | 1012.717540 | 315.993809 |
| 27 | s_000010 | theta | 1795.803489 | 1848.536960 | 1848.536960 | 1795.803489 | 1848.536960 | 52.733470 | 52.733470 | 2.936483 | ... | 527.334705 | 927.435674 | 942.645660 | 15.209986 | 41.366744 | 41.366744 | 0.000000e+00 | 927.435674 | 942.645660 | 15.209986 |
| 28 | s_000011 | theta | 47.532763 | 55.122514 | 55.122514 | 47.532763 | 55.122514 | 7.589750 | 7.589750 | 15.967408 | ... | 75.897503 | 50.231134 | 54.061820 | 3.830686 | 17.924834 | 17.985569 | 6.073555e-02 | 50.231134 | 54.061820 | 3.830686 |
| 29 | s_000012 | theta | 1749.291616 | 1789.241245 | 1789.241245 | 1749.291616 | 1789.241245 | 39.949629 | 39.949629 | 2.283760 | ... | 399.496292 | 899.669216 | 918.444148 | 18.774932 | 39.752742 | 39.752742 | 0.000000e+00 | 899.669216 | 918.444148 | 18.774932 |
| 30 | s_000013 | theta | 1288.180628 | 1664.483038 | 1664.483038 | 1288.180628 | 1664.483038 | 376.302410 | 376.302410 | 29.211929 | ... | 3763.024102 | 774.270085 | 951.484596 | 177.214511 | 106.534781 | 106.534781 | 0.000000e+00 | 774.270085 | 951.484596 | 177.214511 |
| 31 | s_000014 | theta | 849.337387 | 1023.239882 | 1023.239882 | 849.337387 | 1023.239882 | 173.902495 | 173.902495 | 20.475078 | ... | 1739.024947 | 455.253792 | 539.784352 | 84.530560 | 77.586727 | 77.586727 | 0.000000e+00 | 455.253792 | 539.784352 | 84.530560 |
| 32 | s_000015 | theta | 2753.035976 | 3054.381436 | 3054.381436 | 2753.035976 | 3054.381436 | 301.345461 | 301.345461 | 10.945933 | ... | 3013.454607 | 1452.386579 | 1597.319961 | 144.933381 | 100.580558 | 100.580558 | -1.421085e-14 | 1452.386579 | 1597.319961 | 144.933381 |
| 33 | s_000016 | theta | 25.914095 | 40.225368 | 40.225368 | 25.914095 | 40.225368 | 14.311273 | 14.311273 | 55.225824 | ... | 143.112727 | 27.913049 | 40.351256 | 12.438207 | 17.183902 | 22.890008 | 5.706106e+00 | 27.913049 | 40.351256 | 12.438207 |
| 34 | s_000017 | theta | 1562.592855 | 1613.373620 | 1613.373620 | 1562.592855 | 1613.373620 | 50.780765 | 50.780765 | 3.249776 | ... | 507.807648 | 825.369803 | 846.624296 | 21.254493 | 38.596008 | 38.596008 | 0.000000e+00 | 825.369803 | 846.624296 | 21.254493 |
| 35 | s_000018 | theta | 1069.345769 | 1310.210560 | 1310.210560 | 1069.345769 | 1310.210560 | 240.864791 | 240.864791 | 22.524500 | ... | 2408.647914 | 610.712475 | 719.880560 | 109.168085 | 82.536407 | 82.536407 | 0.000000e+00 | 610.712475 | 719.880560 | 109.168085 |
| 36 | s_000019 | theta | 856.352456 | 1195.528411 | 1195.528411 | 856.352456 | 1195.528411 | 339.175955 | 339.175955 | 39.607051 | ... | 3391.759552 | 522.288948 | 686.511566 | 164.222618 | 114.549114 | 114.549114 | 0.000000e+00 | 522.288948 | 686.511566 | 164.222618 |
37 rows × 29 columns
| ts_id | ds | baseline_yhat | allocated_yhat | delta_units | delta_pct | constraint_status | gross_margin_delta | delta_reorder_point | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | __total__ | 2024-12-31 | 1790.214555 | 2077.828335 | 287.613780 | 16.065883 | FREE | 2876.137802 | 2062.837151 |
| 1 | __total__ | 2025-01-01 | 1581.373997 | 1869.955772 | 288.581776 | 18.248800 | FREE | 2885.817755 | 2062.837151 |
| 2 | __total__ | 2025-01-02 | 1699.659054 | 1990.137580 | 290.478526 | 17.090400 | FREE | 2904.785259 | 2062.837151 |
| 3 | __total__ | 2025-01-03 | 2028.794228 | 2322.119798 | 293.325570 | 14.458123 | FREE | 2933.255697 | 2062.837151 |
| 4 | __total__ | 2025-01-04 | 2260.445544 | 2557.482893 | 297.037348 | 13.140655 | FREE | 2970.373482 | 2062.837151 |
| 5 | __total__ | 2025-01-05 | 2299.811011 | 2601.016903 | 301.205891 | 13.096984 | FREE | 3012.058915 | 2062.837151 |
| 6 | __total__ | 2025-01-06 | 2203.760420 | 2508.354680 | 304.594260 | 13.821569 | FREE | 3045.942599 | 2062.837151 |
| 7 | __total__ | 2025-01-07 | 1891.695534 | 2199.116293 | 307.420759 | 16.251070 | FREE | 3074.207591 | 2062.837151 |
| question_id | verdict | answer | evidence | recommendation | |
|---|---|---|---|---|---|
| 0 | model_vs_baseline | verified_lift | Champion 'ensemble_champion' reduced wape by +... | champion=ensemble_champion (wape=0.2769), fva_... | Inspect f.baseline_value_df() and f.compare_mo... |
| 1 | ensemble_vs_single | ensemble_helps | Yes — 'ensemble_champion' outperformed the bes... | best_single=theta@transform_clr (0.2944), best... | Ensembles must beat the best single model by t... |
| 2 | covariates_vs_overfitting | univariate_panel | No external covariates in source data; forecas... | covariates=0 | Inspect f.attributions_df() and f.promo_elasti... |
| 3 | global_vs_local | local_per_series_optimal | Per-series local and zero-shot models are opti... | n_series=4, scale_regime='micro', cross_series... | Global pooling pays off most when n_series >= ... |
| 4 | hierarchy_reconciliation | coherent_and_verified | Flat panel (no hierarchy columns); output.floo... | mode='none', hierarchy_id_cols=[], is_composit... | Inspect f.hierarchy_value_df() for Root, Inter... |
| 5 | horizon_stability | stable_across_horizon | Forecast error remains stable from step 1 to 7... | late_early_ratio=1.00, crossover_step=None, di... | Inspect f.horizon_decay_df() for step-by-step ... |
| 6 | forecast_trust | high_confidence | Evaluated on 1 rolling out-of-fold backtest wi... | n_folds=1, champion_pass=1/1, residual_acf1=-0... | Inspect f.explain_auto_decisions_df() for the ... |
Assortment Rationalization (Track Q.2): Retained 4/20 SKUs | Transferred: 6,799.3u | Category Retention: 61.4% Integer Pre-Pack MILP (Track R.2): 56,670u allocated | Fill Rate: 100.0% | Overstock: 37.1u Lateral Store Rebalancing (Track R.2): Transferred 12,340.4u | Net Cost Savings: +$277,659.19
Where next¶
- Next in Track 3 (Accuracy & Post-Processing):
07_hpo_backtesting_and_ensembles.ipynb— combine Optuna hyperparameter tuning, 4 backtest schemes, and in-run, post-run, and cross-run ensembling. - Documentation: Configuration reference (
hierarchy) · Backtesting guide · Cost estimates & controls