|
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.
08 · The Multi-Family Parallel Master Workflow: Multi-Engine DAG, Foundation Models, Explainability, Ensembles & Inventory Policy¶
This notebook demonstrates the flagship architecture of scale-forecasting: a single RunConfig that routes active model families in parallel across their optimal cloud runtimes (dag.py & router.py — mixing spark, vertex, gce, gke, ray, vertex_automl, and bigquery, or running all Python families on a single shared gke cluster with dedicated CPU and GPU node pools), tears down each family's compute the instant it finishes (zero-idle per-family compute), joins all families in a downstream stacked ensemble stage, and runs the full post-run decision workbench (FVA, Two-Tier Explainability, Anomalies & Change Points, and Operational Inventory Replenishment Policies).
At a glance¶
| Dimension | Details |
|---|---|
| Learning outcomes | Dispatch a single RunConfig across parallel per-family jobs (statistical, ml, deep_learning including [models-foundation] chronos_bolt, native, and optional automl), inspect v_run_jobs provisioning vs. execution telemetry and version parity, blend all families in a stacked ensemble, and run FVA, TreeSHAP attributions, anomaly/change-point detection, and $(s, S)$ inventory replenishment policies. |
| Prerequisites | Deployed scale-forecasting Google Cloud project (SF_* env vars) + scale-forecasting[gcp]. |
| Estimated time | ~8–15 minutes for the 4-family run (+ ~45–75 minutes if optional vertex_automl Tabular Workflow is enabled). |
| Estimated run cost | Estimated ~\$0.25–\$1.00 USD for statistical + ml + deep_learning + native (Dataproc / Vertex AI / GCE / GKE CPU & GPU minutes + BigQuery). Enabling optional vertex_automl adds an estimated ~\$3–\$22 USD (Vertex AI Pipelines, Dataflow, and AutoML training/batch prediction node-hours). |
| Ongoing cost | Zero compute when idle (each family's batch, VM, or pod exits immediately upon finishing its models). |
flowchart LR
CFG["Single RunConfig
1 Deterministic run_id"] --> DAG["dag.plan_dag()
Per-Family Parallel Router"]
subgraph Parallel["Concurrent Family Execution (Zero-Idle Compute Across 5 Families)"]
F1["statistical
theta · holtwinters
(Spark, Vertex, GCE, or GKE CPU)"]
F2["ml
lightgbm · xgboost
(Vertex or GKE CPU · Two-Tier TreeSHAP)"]
F3["deep_learning
tide · chronos_bolt
(Vertex, GKE, or Ray CPU/GPU)"]
F4["automl (Optional)
vertex_tide · vertex_l2l
(Vertex AI AutoML Tabular Workflow)"]
F5["native
arima_plus · timesfm
(BigQuery Serverless SQL)"]
end
DAG --> F1 & F2 & F3 & F4 & F5 --> ENS["ensemble Stage
inverse_error · nnls · ridge · champion"]
ENS --> LB["v_model_leaderboard + Decision Workbench
FVA · Attributions · Anomalies · Inventory Policy"]
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 the Multi-Family Master DAG & Inspect forecaster.explain()¶
Look at how forecaster.explain() decomposes our single RunConfig into independent family execution rows, each with its own runtime (spark, vertex, gce, gke, ray, vertex_automl, or bigquery), training mode (local vs. global), hardware (cpu vs. gpu), and sizing. (When routing families to runtime='gke', shared_clusters.py provisions a single shared GKE cluster with fit-for-purpose CPU and GPU node pools per family and scales down individual GPU nodes as each deep_learning model pod finishes.)
import time
from scale_forecasting import Forecaster, RunConfig
# === Parameters — edit me ===============================================
RUN_NAME = f"nb08 master workflow {int(time.time())}"
SOURCE_TABLE = "source_series_iceberg"
MODELS = ["theta", "holtwinters", "lightgbm", "xgboost", "tide", "chronos_bolt", "arima_plus", "timesfm"]
HORIZON = 28
SERIES_LIMIT = 15
N_FOLDS = 2
ENSEMBLE_STRATEGIES = ["mean", "inverse_error", "nnls", "ridge", "champion"]
# ========================================================================
cfg = RunConfig(
run_name=RUN_NAME,
python_runtime="spark",
data={"source_table": SOURCE_TABLE, "horizon": HORIZON, "series_limit": SERIES_LIMIT},
models=MODELS,
model_params={
"tide": {"training_mode": "global", "max_epochs": 15},
},
compute={
"families": {
"statistical": {"runtime": "spark"},
"ml": {"runtime": "vertex", "machine_type": "n2-standard-4", "workers": 1},
"deep_learning": {"runtime": "vertex", "hardware": "cpu", "machine_type": "n2-standard-4", "workers": 1},
}
},
features={"holidays": ["US"]},
backtest={"enabled": True, "n_folds": N_FOLDS, "horizon": HORIZON, "step": HORIZON},
ensemble={"enabled": True, "strategies": ENSEMBLE_STRATEGIES},
)
forecaster = Forecaster(cfg, settings=settings)
print("Master run_id:", forecaster.run_id)
display(forecaster.explain())
# Also inspect the DAG node topology directly via forecaster.dag()
for node in forecaster.dag():
print(f" DAG node: {node.family:<15} runtime={node.runtime:<10} hardware={str(node.hardware):<5} models={list(node.models)} depends_on={list(node.depends_on)}")
# Preview how adding an 'automl' model (e.g. vertex_tide) expands the DAG to all 5 families:
five_family_preview = cfg.model_copy(update={"models": [*MODELS, "vertex_tide"]})
print("\n--- 5-Family Execution Plan Preview (adding vertex_tide on vertex_automl) ---")
display(Forecaster(five_family_preview, settings=settings).explain(validate_data=False))
Master run_id: nb08-master-workflow-1792704406-9a68c0de33d3
| 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 | nb08-master-workflow-1792704406-9a68c0de33d3 | statistical | sf-nb08-master-workflow-1792704406-9a68c0de33d... | spark | None | NaN | cpu | None | theta, holtwinters | theta:local, holtwinters:local | 15 | 2 | 30 | none | |
| 1 | nb08-master-workflow-1792704406-9a68c0de33d3 | ml | sf-nb08-master-workflow-1792704406-9a68c0de33d... | vertex | n2-standard-4 | 1.0 | cpu | None | lightgbm, xgboost | lightgbm:local, xgboost:local | 15 | 2 | 30 | none | |
| 2 | nb08-master-workflow-1792704406-9a68c0de33d3 | deep_learning | sf-nb08-master-workflow-1792704406-9a68c0de33d... | vertex | n2-standard-4 | 2.0 | cpu | None | tide, chronos_bolt | tide:global, chronos_bolt:local | 15 | 2 | 30 | none | |
| 3 | nb08-master-workflow-1792704406-9a68c0de33d3 | native | sf-nb08-master-workflow-1792704406-9a68c0de33d... | bigquery | sql | 1.0 | sql | None | arima_plus, timesfm | arima_plus:local, timesfm:local | 15 | 2 | 30 | none | |
| 4 | nb08-master-workflow-1792704406-9a68c0de33d3 | ensemble | sf-nb08-master-workflow-1792704406-9a68c0de33d... | bigquery | sql | 1.0 | sql | None | ensemble_mean, ensemble_inverse_error, ensembl... | barrier | 15 | 2 | 75 | none | sf-nb08-master-workflow-1792704406-9a68c0de33d... |
DAG node: statistical runtime=spark hardware=cpu models=['theta', 'holtwinters'] depends_on=[] DAG node: ml runtime=vertex hardware=cpu models=['lightgbm', 'xgboost'] depends_on=[] DAG node: deep_learning runtime=vertex hardware=cpu models=['tide', 'chronos_bolt'] depends_on=[] DAG node: native runtime=bigquery hardware=None models=['arima_plus', 'timesfm'] depends_on=[] DAG node: ensemble runtime=bigquery hardware=None models=[] depends_on=['sf-nb08-master-workflow-1792704406-9a68c0de33d3-statistical-a1', 'sf-nb08-master-workflow-1792704406-9a68c0de33d3-ml-a1', 'sf-nb08-master-workflow-1792704406-9a68c0de33d3-deep_learning-a1', 'sf-nb08-master-workflow-1792704406-9a68c0de33d3-native-a1'] --- 5-Family Execution Plan Preview (adding vertex_tide on vertex_automl) ---
| 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 | nb08-master-workflow-1792704406-0fbd8e126496 | statistical | sf-nb08-master-workflow-1792704406-0fbd8e12649... | spark | None | NaN | cpu | None | theta, holtwinters | theta:local, holtwinters:local | 15 | 2 | 30 | none | |
| 1 | nb08-master-workflow-1792704406-0fbd8e126496 | ml | sf-nb08-master-workflow-1792704406-0fbd8e12649... | vertex | n2-standard-4 | 1.0 | cpu | None | lightgbm, xgboost | lightgbm:local, xgboost:local | 15 | 2 | 30 | none | |
| 2 | nb08-master-workflow-1792704406-0fbd8e126496 | deep_learning | sf-nb08-master-workflow-1792704406-0fbd8e12649... | vertex | n2-standard-4 | 2.0 | cpu | None | tide, chronos_bolt | tide:global, chronos_bolt:local | 15 | 2 | 30 | none | |
| 3 | nb08-master-workflow-1792704406-0fbd8e126496 | automl | sf-nb08-master-workflow-1792704406-0fbd8e12649... | vertex_automl | None | NaN | cpu | None | vertex_tide | vertex_tide:global | 15 | 2 | 15 | none | |
| 4 | nb08-master-workflow-1792704406-0fbd8e126496 | native | sf-nb08-master-workflow-1792704406-0fbd8e12649... | bigquery | sql | 1.0 | sql | None | arima_plus, timesfm | arima_plus:local, timesfm:local | 15 | 2 | 30 | none | |
| 5 | nb08-master-workflow-1792704406-0fbd8e126496 | ensemble | sf-nb08-master-workflow-1792704406-0fbd8e12649... | bigquery | sql | 1.0 | sql | None | ensemble_mean, ensemble_inverse_error, ensembl... | barrier | 15 | 2 | 75 | none | sf-nb08-master-workflow-1792704406-0fbd8e12649... |
Act 3 · Launch & Monitor All Families Concurrently (forecaster.run_live())¶
forecaster.run_live() launches the parallel family threads, displays real-time per-family progress bars, escalates to live platform probes (probe=True) if any engine is quiet for >300s, and runs the final ensemble join.
result = forecaster.run_live(poll_s=15.0, probe=True)
print(f"Master workflow {result.run_id} finished: status={result.status}, wall_clock={result.runtime_seconds:.1f}s")
Master workflow nb08-master-workflow-1792704406-9a68c0de33d3 finished: status=COMPLETED, wall_clock=1183.1s
Act 4 · Comprehensive Post-Run Review (Leaderboard, FVA, Cohorts, Provisioning Telemetry, Calibration, Ensemble Weights, Two-Tier Feature Attributions, Anomalies, Change Points & Inventory Policy)¶
Let's run the complete diagnostic & decision workbench suite across all active model families and the stacked ensembles:
leaderboard_df(),plot_leaderboard(),plot_metric_distribution(), andfva_df()(Forecast Value Added & Diebold–Mariano $p$-values)cohorts_df()andjobs_df()(includingprovision_secondsvs.execute_secondsandlauncher_version/worker_versionparity)plot_calibration()andplot_ensemble_weights()- Two-Tier Feature Attributions:
attributions_df()andplot_attributions()(Tier 1 global feature importance + Tier 2 per-horizon-step TreeSHAP attributions) plot_forecasts(),plot_forecast_explanation(), andplot_trace()- Universal Anomaly & Structural Change-Point Detection (
detect_anomalies_df()&detect_change_points_df()) - Operational Inventory & Replenishment Policy (
inventory_policy_df()&plot_inventory_policy())
import matplotlib.pyplot as plt
from scale_forecasting import (
plot_leaderboard,
plot_metric_distribution,
plot_trace,
)
display(forecaster.leaderboard_df())
review = forecaster.review_run()
plot_leaderboard(review)
plt.show()
plot_metric_distribution(review)
plt.show()
print("--- Forecast Value Added (fva_df) ---")
display(forecaster.fva_df())
display(forecaster.cohorts_df())
display(forecaster.jobs_df())
forecaster.plot_calibration()
plt.show()
forecaster.plot_ensemble_weights()
plt.show()
print("--- Two-Tier Feature Attributions (forecaster.attributions_df & plot_attributions) ---")
attr_df = forecaster.attributions_df(model_type="xgboost", level="global")
if not attr_df.empty:
display(attr_df.head(10))
forecaster.plot_attributions(model_type="xgboost", level="global", title="Tier 1 Global TreeSHAP Importance (xgboost)")
plt.show()
forecaster.plot_attributions(model_type="xgboost", level="local", title="Tier 2 Local Per-Step TreeSHAP Attributions (xgboost)")
plt.show()
forecaster.plot_forecasts(history_tail=120)
plt.show()
forecaster.plot_forecast_explanation(history_tail=120)
plt.show()
trace_df = forecaster.trace()
display(trace_df)
plot_trace(trace_df)
plt.show()
print("--- Universal Anomaly & Structural Change-Point Detection (ensemble_nnls) ---")
display(forecaster.detect_anomalies_df(model_name="ensemble_nnls", anomalies_only=True).head(10))
display(forecaster.detect_change_points_df(model_name="ensemble_nnls").head(10))
print("--- Operational Inventory & Replenishment Policy (Continuous Review (s, S) @ 95% CSL) ---")
inv_df = forecaster.inventory_policy_df(
model_name="ensemble_nnls",
lead_time=7.0,
service_level=0.95,
on_hand=150.0,
holding_cost=1.0,
stockout_cost=9.0,
)
display(
inv_df[
[
"ts_id",
"model_type",
"lead_time_demand",
"error_autocorr_rho",
"safety_stock",
"reorder_point",
"recommended_order_qty",
"expected_total_cost",
]
].head(10)
)
forecaster.plot_inventory_policy(
model_name="ensemble_nnls",
lead_time=7.0,
service_level=0.95,
on_hand=150.0,
max_rows=10,
)
plt.show()
| rank | model_type | base_model | family | scope_capability | training_mode | cov_profile | is_univariate | covariates_used | model_spec_hash | ... | 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 | timesfm | timesfm | native | None | None | None | None | None | None | ... | 11.005609 | 15.293734 | 0.763095 | 50.671062 | NaN | NaN | 1.0 | 420 | NaN | NaN |
| 1 | 2 | ensemble_champion | ensemble_champion | ensemble | None | None | None | None | None | None | ... | 10.440083 | 14.544251 | 0.751190 | 57.512068 | NaN | NaN | 1.0 | 420 | -0.000886 | -0.002451 |
| 2 | 3 | ensemble_ridge | ensemble_ridge | ensemble | None | None | None | None | None | None | ... | 11.006456 | 15.127776 | 0.801190 | 58.044696 | NaN | NaN | 0.0 | 420 | -0.020409 | -0.056487 |
| 3 | 4 | ensemble_nnls | ensemble_nnls | ensemble | None | None | None | None | None | None | ... | 11.038614 | 15.033972 | 0.813095 | 60.147113 | NaN | NaN | 0.0 | 420 | -0.024913 | -0.068953 |
| 4 | 5 | holtwinters | holtwinters | statistical | None | None | None | None | None | None | ... | 12.934460 | 17.531664 | 0.698810 | 65.546850 | 3.158146 | 1.844613 | 1.0 | 420 | NaN | NaN |
| 5 | 6 | ensemble_inverse_error | ensemble_inverse_error | ensemble | None | None | None | None | None | None | ... | 11.039669 | 14.959681 | 0.803571 | 61.440821 | NaN | NaN | 1.0 | 420 | -0.026688 | -0.073865 |
| 6 | 7 | chronos_bolt | chronos_bolt | deep_learning | None | None | None | None | None | None | ... | 12.646913 | 16.922808 | 0.736905 | 57.914674 | 4.654701 | 1.323074 | 1.0 | 420 | NaN | NaN |
| 7 | 8 | ensemble_mean | ensemble_mean | ensemble | None | None | None | None | None | None | ... | 11.977868 | 16.051008 | 0.794048 | 65.576328 | NaN | NaN | 1.0 | 420 | -0.040236 | -0.111362 |
| 8 | 9 | arima_plus | arima_plus | native | None | None | None | None | None | None | ... | 11.596456 | 15.484153 | 0.617857 | 56.040233 | NaN | NaN | 1.0 | 420 | NaN | NaN |
| 9 | 10 | lightgbm | lightgbm | ml | None | None | None | None | None | None | ... | 13.821479 | 18.199157 | 0.282143 | 99.018758 | 5.981903 | 3.206135 | 1.0 | 420 | NaN | NaN |
| 10 | 11 | theta | theta | statistical | None | None | None | None | None | None | ... | 14.614160 | 18.970049 | 0.995238 | 262.555296 | 4.493169 | 2.187829 | 1.0 | 420 | NaN | NaN |
| 11 | 12 | xgboost | xgboost | ml | None | None | None | None | None | None | ... | 14.319092 | 19.378332 | 0.210714 | 116.923408 | 5.674563 | 5.751357 | 1.0 | 420 | NaN | NaN |
| 12 | 13 | tide | tide | deep_learning | multi_scope | global | cov_none | True | d4804fdf4a4fc1cf | ... | 17.900452 | 22.432844 | 0.771429 | 90.109112 | 5.028947 | 5.028947 | 1.0 | 420 | NaN | NaN |
13 rows × 34 columns
--- Forecast Value Added (fva_df) ---
| fva_stage_rank | fva_stage | model_type | base_model | demand_class | n_series | n_points | metric | mean_metric | pooled_wape | ... | univariate_baseline_model | covariate_fva_abs | covariate_fva_pct | covariate_p_value_dm | covariate_significant_at_05 | local_baseline_model | pooling_fva_abs | pooling_fva_pct | pooling_p_value_dm | pooling_significant_at_05 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | Baseline | arima_plus | arima_plus | all | 15 | 840 | wape | 0.403000 | 0.135709 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 1 | 2 | Statistical / SQL | timesfm | timesfm | all | 15 | 840 | wape | 0.352232 | 0.128794 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 2 | 2 | Statistical | holtwinters | holtwinters | all | 15 | 840 | wape | 0.381727 | 0.151367 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 3 | 2 | Statistical | theta | theta | all | 15 | 840 | wape | 0.432903 | 0.171024 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 4 | 3 | Machine Learning | lightgbm | lightgbm | all | 15 | 840 | wape | 0.433242 | 0.161747 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 5 | 3 | Machine Learning | xgboost | xgboost | all | 15 | 840 | wape | 0.435188 | 0.167571 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 6 | 4 | Deep Learning | chronos_bolt | chronos_bolt | all | 15 | 840 | wape | 0.381411 | 0.148002 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 7 | 4 | Deep Learning | tide | tide | all | 15 | 840 | wape | 0.476087 | 0.209482 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 8 | 6 | Ensemble | ensemble_champion | ensemble_champion | all | 15 | 840 | wape | 0.352719 | 0.122176 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 9 | 6 | Ensemble | ensemble_ridge | ensemble_ridge | all | 15 | 840 | wape | 0.374321 | 0.128804 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 10 | 6 | Ensemble | ensemble_nnls | ensemble_nnls | all | 15 | 840 | wape | 0.376681 | 0.129180 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 11 | 6 | Ensemble | ensemble_inverse_error | ensemble_inverse_error | all | 15 | 840 | wape | 0.377714 | 0.129193 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
| 12 | 6 | Ensemble | ensemble_mean | ensemble_mean | all | 15 | 840 | wape | 0.390779 | 0.140172 | ... | None | NaN | NaN | NaN | False | None | NaN | NaN | NaN | False |
13 rows × 30 columns
| model_type | family | is_ensemble | n_series | score | pooled_wape | n_comparable_series | n_full | n_reduced | n_unscored | n_failed | n_not_requested | fold_histogram | refit_modes | staleness_gap | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | timesfm | native | False | 15 | 0.361305 | 0.114330 | 15 | 15 | 0 | 0 | 0 | 0 | 2f:15 | per_fold:15 | None |
| 1 | ensemble_champion | ensemble | True | 15 | 0.362190 | 0.111546 | 15 | 0 | 0 | 0 | 0 | 15 | none | per_fold:15 | None |
| 2 | ensemble_ridge | ensemble | True | 15 | 0.381714 | 0.121857 | 15 | 0 | 0 | 0 | 0 | 15 | none | per_fold:15 | None |
| 3 | ensemble_nnls | ensemble | True | 15 | 0.386218 | 0.116365 | 15 | 0 | 0 | 0 | 0 | 15 | none | per_fold:15 | None |
| 4 | holtwinters | statistical | False | 15 | 0.387183 | 0.135680 | 15 | 15 | 0 | 0 | 0 | 0 | 2f:15 | per_fold:15 | None |
| 5 | ensemble_inverse_error | ensemble | True | 15 | 0.387992 | 0.117575 | 15 | 0 | 0 | 0 | 0 | 15 | none | per_fold:15 | None |
| 6 | chronos_bolt | deep_learning | False | 15 | 0.397640 | 0.126006 | 15 | 15 | 0 | 0 | 0 | 0 | 2f:15 | per_fold:15 | None |
| 7 | ensemble_mean | ensemble | True | 15 | 0.401540 | 0.123601 | 15 | 0 | 0 | 0 | 0 | 15 | none | per_fold:15 | None |
| 8 | arima_plus | native | False | 15 | 0.413395 | 0.125555 | 15 | 15 | 0 | 0 | 0 | 0 | 2f:15 | per_fold:15 | None |
| 9 | lightgbm | ml | False | 15 | 0.441840 | 0.151010 | 15 | 15 | 0 | 0 | 0 | 0 | 2f:15 | per_fold:15 | None |
| 10 | theta | statistical | False | 15 | 0.443389 | 0.158292 | 15 | 15 | 0 | 0 | 0 | 0 | 2f:15 | per_fold:15 | None |
| 11 | xgboost | ml | False | 15 | 0.448197 | 0.139390 | 15 | 15 | 0 | 0 | 0 | 0 | 2f:15 | per_fold:15 | None |
| 12 | tide | deep_learning | False | 15 | 0.489635 | 0.199350 | 15 | 15 | 0 | 0 | 0 | 0 | 2f:15 | per_fold:15 | None |
| family | job_key | system_job_id | runtime | status | attempt | hardware | gpu_type | spark_mode | runtime_seconds | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | deep_learning | sf-nb08-master-workflow-1792704406-9a68c0de33d... | projects/307701787156/locations/us-central1/cu... | vertex | COMPLETED | 1 | cpu | None | None | 1141.878434 |
| 1 | ensemble | sf-nb08-master-workflow-1792704406-9a68c0de33d... | sf-nb08-master-workflow-1792704406-9a68c0de33d... | bigquery | COMPLETED | 1 | None | None | None | 21.344402 |
| 2 | ml | sf-nb08-master-workflow-1792704406-9a68c0de33d... | projects/307701787156/locations/us-central1/cu... | vertex | COMPLETED | 1 | cpu | None | None | 1067.939585 |
| 3 | native | sf-nb08-master-workflow-1792704406-9a68c0de33d... | sf-nb08-master-workflow-1792704406-9a68c0de33d... | bigquery | COMPLETED | 1 | None | None | None | 97.754836 |
| 4 | statistical | sf-nb08-master-workflow-1792704406-9a68c0de33d... | sf-nb08-master-workflow-1792704406-9a68c0de33d... | spark | COMPLETED | 1 | cpu | None | serverless | 508.576068 |
--- Two-Tier Feature Attributions (forecaster.attributions_df & plot_attributions) ---
| ts_id | model_type | compute_engine | feature | importance | |
|---|---|---|---|---|---|
| 0 | s_000000 | xgboost | vertex | lag_7 | 0.739868 |
| 1 | s_000000 | xgboost | vertex | lag_14 | 0.139584 |
| 2 | s_000000 | xgboost | vertex | is_holiday | 0.048060 |
| 3 | s_000000 | xgboost | vertex | doy | 0.018106 |
| 4 | s_000000 | xgboost | vertex | month | 0.017481 |
| 5 | s_000000 | xgboost | vertex | dow | 0.012837 |
| 6 | s_000000 | xgboost | vertex | lag_28 | 0.007346 |
| 7 | s_000000 | xgboost | vertex | lag_1 | 0.006607 |
| 8 | s_000000 | xgboost | vertex | lag_3 | 0.003971 |
| 9 | s_000000 | xgboost | vertex | dom | 0.003362 |
| kind | lane | label | start | end | duration_s | status | runtime | model_type | ts_id | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | job | deep_learning | deep_learning | 2026-10-22 21:27:12.279867+00:00 | 2026-10-22 21:46:17.698463+00:00 | 1145.418596 | COMPLETED | vertex | None | None |
| 1 | job | ensemble | ensemble | 2026-10-22 21:46:22.854790+00:00 | 2026-10-22 21:46:46.895305+00:00 | 24.040515 | COMPLETED | bigquery | None | None |
| 2 | job | ml | ml | 2026-10-22 21:27:12.223518+00:00 | 2026-10-22 21:45:03.589245+00:00 | 1071.365727 | COMPLETED | vertex | None | None |
| 3 | job | native | native | 2026-10-22 21:27:12.260026+00:00 | 2026-10-22 21:28:53.674095+00:00 | 101.414069 | COMPLETED | bigquery | None | None |
| 4 | job | statistical | statistical | 2026-10-22 21:27:12.269689+00:00 | 2026-10-22 21:35:44.331765+00:00 | 512.062076 | COMPLETED | spark | None | None |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 90 | cell | cmle-training-workerpool1-797140d45e-0:1 | chronos_bolt:s_000011 | 2026-10-22 21:44:58.781617+00:00 | 2026-10-22 21:45:00.033390+00:00 | 1.251773 | None | vertex | chronos_bolt | s_000011 |
| 91 | cell | cmle-training-workerpool1-797140d45e-0:1 | chronos_bolt:s_000007 | 2026-10-22 21:45:00.034259+00:00 | 2026-10-22 21:45:01.258394+00:00 | 1.224135 | None | vertex | chronos_bolt | s_000007 |
| 92 | cell | cmle-training-workerpool1-797140d45e-0:1 | chronos_bolt:s_000006 | 2026-10-22 21:45:01.259613+00:00 | 2026-10-22 21:45:02.691280+00:00 | 1.431667 | None | vertex | chronos_bolt | s_000006 |
| 93 | cell | cmle-training-workerpool1-797140d45e-0:1 | chronos_bolt:s_000005 | 2026-10-22 21:45:02.692511+00:00 | 2026-10-22 21:45:04.164506+00:00 | 1.471995 | None | vertex | chronos_bolt | s_000005 |
| 94 | cell | cmle-training-workerpool1-797140d45e-0:1 | chronos_bolt:s_000008 | 2026-10-22 21:45:04.165835+00:00 | 2026-10-22 21:45:05.561333+00:00 | 1.395498 | None | vertex | chronos_bolt | s_000008 |
95 rows × 10 columns
--- Universal Anomaly & Structural Change-Point Detection (ensemble_nnls) ---
| ts_id | model_type | ds | y | yhat | is_anomaly | anomaly_probability | lower_bound | upper_bound | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | s_000000 | ensemble_nnls | 2024-11-11 | 216.978 | 189.744890 | True | 0.994167 | 170.384866 | 209.104914 |
| 1 | s_000000 | ensemble_nnls | 2024-12-25 | 204.093 | 175.845786 | True | 0.995759 | 156.485762 | 195.205810 |
| 2 | s_000001 | ensemble_nnls | 2024-11-26 | 17.494 | 1.420978 | True | 0.999989 | -5.747598 | 8.589555 |
| 3 | s_000001 | ensemble_nnls | 2024-12-18 | 8.790 | 1.380567 | True | 0.957216 | -5.788009 | 8.549144 |
| 4 | s_000001 | ensemble_nnls | 2024-12-29 | 9.121 | 1.638665 | True | 0.959219 | -5.529911 | 8.807241 |
| 5 | s_000002 | ensemble_nnls | 2024-12-12 | 172.680 | 153.399286 | True | 0.952744 | 134.352117 | 172.446456 |
| 6 | s_000002 | ensemble_nnls | 2024-12-25 | 178.345 | 154.564380 | True | 0.985596 | 135.517211 | 173.611550 |
| 7 | s_000002 | ensemble_nnls | 2024-12-28 | 205.475 | 182.051491 | True | 0.984060 | 163.004321 | 201.098660 |
| 8 | s_000002 | ensemble_nnls | 2024-12-29 | 214.760 | 187.032047 | True | 0.995672 | 167.984877 | 206.079216 |
| 9 | s_000003 | ensemble_nnls | 2024-11-25 | 77.486 | 119.505885 | True | 0.988916 | 87.082389 | 151.929381 |
| ts_id | model_type | begin_date | end_date | window_count | window_avg | window_min | window_max | window_stddev | gap_edge_missing_steps | is_gap_edge | status | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | s_000002 | ensemble_nnls | 2024-12-02 | 2024-12-08 | 7 | 170.627571 | 150.312 | 188.021 | 14.580563 | 0 | False | |
| 1 | s_000002 | ensemble_nnls | 2024-12-19 | 2024-12-25 | 7 | 178.292714 | 157.452 | 204.105 | 15.098823 | 0 | False | |
| 2 | s_000003 | ensemble_nnls | 2024-11-16 | 2024-11-22 | 7 | 71.684714 | 58.930 | 85.839 | 9.627494 | 0 | False | |
| 3 | s_000003 | ensemble_nnls | 2024-11-30 | 2024-12-06 | 7 | 80.028429 | 71.174 | 93.643 | 8.161444 | 0 | False | |
| 4 | s_000003 | ensemble_nnls | 2024-12-21 | 2024-12-27 | 7 | 89.104286 | 84.609 | 92.511 | 2.615408 | 0 | False | |
| 5 | s_000004 | ensemble_nnls | 2024-11-14 | 2024-11-20 | 7 | 67.413000 | 15.531 | 109.185 | 37.721467 | 0 | False | |
| 6 | s_000004 | ensemble_nnls | 2024-11-21 | 2024-11-27 | 7 | 86.360571 | 17.381 | 151.681 | 51.084085 | 0 | False | |
| 7 | s_000004 | ensemble_nnls | 2024-12-01 | 2024-12-07 | 7 | 40.787429 | 0.000 | 88.440 | 39.625923 | 0 | False | |
| 8 | s_000004 | ensemble_nnls | 2024-12-18 | 2024-12-24 | 7 | 80.608429 | 10.730 | 150.836 | 54.203511 | 0 | False | |
| 9 | s_000006 | ensemble_nnls | 2024-11-09 | 2024-11-15 | 7 | 1.408571 | 0.000 | 3.587 | 1.764598 | 0 | False |
--- Operational Inventory & Replenishment Policy (Continuous Review (s, S) @ 95% CSL) ---
| ts_id | model_type | lead_time_demand | error_autocorr_rho | safety_stock | reorder_point | recommended_order_qty | expected_total_cost | |
|---|---|---|---|---|---|---|---|---|
| 0 | s_000000 | ensemble_nnls | 1488.009142 | 0.128558 | 85.870700 | 1573.879843 | 1423.879843 | 96.778011 |
| 1 | s_000001 | ensemble_nnls | 11.562552 | 0.146052 | 25.330189 | 36.892741 | 0.000000 | 28.547634 |
| 2 | s_000002 | ensemble_nnls | 1250.672051 | 0.548821 | 93.845586 | 1344.517638 | 1194.517638 | 105.765869 |
| 3 | s_000003 | ensemble_nnls | 611.436322 | 0.572329 | 101.813663 | 713.249985 | 563.249985 | 114.746052 |
| 4 | s_000004 | ensemble_nnls | 394.701112 | 0.645650 | 338.841204 | 733.542316 | 583.542316 | 381.880872 |
| 5 | s_000005 | ensemble_nnls | 1744.746767 | 0.205336 | 44.041535 | 1788.788302 | 1638.788302 | 49.635698 |
| 6 | s_000006 | ensemble_nnls | 7.992938 | 0.053293 | 10.896748 | 18.889686 | 0.000000 | 12.280854 |
| 7 | s_000007 | ensemble_nnls | 1102.088819 | 0.337797 | 112.652727 | 1214.741546 | 1064.741546 | 126.961896 |
| 8 | s_000008 | ensemble_nnls | 299.902608 | -0.047925 | 258.942786 | 558.845394 | 408.845394 | 291.833743 |
| 9 | s_000009 | ensemble_nnls | 471.285452 | 0.780054 | 734.379000 | 1205.664452 | 1055.664452 | 827.659947 |
Act 5 · Glass-Box Auto-Forecaster, 7-Runtime Duration Predictor & Track L Prescriptive Risk Workbench¶
Instead of hand-crafting the multi-family RunConfig above, Forecaster.build_config() inspects a panel (or BigQuery table) and compiles the full multi-engine configuration with per-family critical-path duration estimates (predict_run_duration()), explored in full in 11_auto_forecaster_and_autofocus.ipynb. On the completed multi-engine cloud run, the Track L Risk & Prescriptive Workbench adds:
- Online Adaptive Conformal Inference (
forecaster.aci_df(),forecaster.plot_aci()): Tracks rolling empirical interval coverage and adaptive miscoverage rate $\alpha_t$ with EWMA volatility normalization (aci_normalized). - Joint Cross-Series & Cross-Horizon Copula Tail Risk (
forecaster.sample_trajectories(),forecaster.tail_risk_df(),forecaster.plot_trajectories()): Simulates correlated trajectory paths across series and horizons to quantify portfolio Value-at-Risk (var_alpha) and Expected Shortfall (cvar_alpha). - Portfolio-Constrained Multi-SKU Inventory Optimizer (
forecaster.optimize_inventory_df(),forecaster.plot_inventory_frontier()): Allocates working-capital budget (max_budget) and safety stock across SKUs to meet an aggregate portfolio fill-rate target (target_portfolio_fill_rate=0.95). - Prescriptive Price & Promo Calendar Optimizer (
forecaster.optimize_scenario(),forecaster.plot_optimal_scenario()): Solves for the CVaR-adjusted profit-maximizing forward price and promotional schedule over the Double-ML causal elasticity surface.
import warnings
warnings.filterwarnings("ignore")
from scale_forecasting import predict_run_duration
# 1. Estimate wall-clock critical path across parallel families for the Master Workflow RunConfig
dur_est = predict_run_duration(forecaster.config, n_series=15)
print(
f"Estimated critical path ({dur_est.critical_path_family}): "
f"p50={dur_est.total_p50_seconds:.0f}s ({dur_est.total_p50_minutes:.2f}m), "
f"p90={dur_est.total_p90_seconds:.0f}s"
)
display(dur_est.to_dataframe())
# 2. Compile an editable Glass-Box ConfigBlueprint for 'deep_sky' across cloud runtimes
bp_cloud = Forecaster.build_config(
SOURCE_TABLE,
tier="deep_sky",
where="cloud_all",
settings=settings,
)
display(bp_cloud.rationale_df)
display(bp_cloud.duration_estimate.to_dataframe())
# 3. Track L Risk & Prescriptive Decisioning on the Live Multi-Engine Cloud Run
print("--- 3a. Online Adaptive Conformal Inference (forecaster.aci_df) ---")
aci_cloud_df = forecaster.aci_df(gamma=0.05, normalized=True)
display(aci_cloud_df.head(6))
forecaster.plot_aci(aci_cloud_df)
plt.show()
print("--- 3b. Joint Copula Trajectories & Portfolio VaR / CVaR Tail Risk ---")
traj_cloud_df = forecaster.sample_trajectories(n_paths=200, copula_type="auto")
tail_risk_cloud_df = forecaster.tail_risk_df(traj_cloud_df, window=7, alphas=(0.90, 0.95, 0.99))
display(tail_risk_cloud_df.head(6))
forecaster.plot_trajectories(traj_cloud_df, max_paths_shown=30)
plt.show()
print("--- 3c. Portfolio-Constrained Multi-SKU Inventory Replenishment ---")
inv_opt_cloud_df = forecaster.optimize_inventory_df(
trajectories_df=traj_cloud_df,
max_budget=50000.0,
target_portfolio_fill_rate=0.95,
uncertainty_source="copula",
)
display(inv_opt_cloud_df.head(8))
forecaster.plot_inventory_frontier(inv_opt_cloud_df)
plt.show()
print("--- 3d. Prescriptive Price & Promotional Calendar Optimization (CVaR Risk-Adjusted Profit) ---")
scen_opt_cloud = forecaster.optimize_scenario(
objective="risk_adjusted_profit",
price_bounds=(-0.10, 0.10),
max_promo_days=4,
min_cooldown_days=2,
risk_aversion_lambda=0.25,
)
display(scen_opt_cloud.schedule_df.head(8))
forecaster.plot_optimal_scenario(scen_opt_cloud)
plt.show()
Estimated critical path (statistical): p50=238s (3.97m), p90=502s
| family | runtime | mode | hardware | n_models | n_borrowed | n_executed | parallel_slots | provision_p50_s | io_s | exec_p50_s | total_p50_s | total_p90_s | estimated_usd | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | statistical | spark | serverless | cpu | 2 | 0 | 2 | 19 | 64.4 | 2.3 | 165.6 | 232.3 | 296.0 | 0.064 |
| 1 | ml | vertex | custom_job | cpu | 2 | 0 | 2 | 8 | 142.5 | 2.3 | 48.7 | 193.5 | 494.2 | 0.020 |
| 2 | deep_learning | vertex | custom_job | cpu | 2 | 0 | 2 | 8 | 142.5 | 2.3 | 47.6 | 192.3 | 492.3 | 0.020 |
| 3 | native | bigquery | sql | cpu | 2 | 0 | 2 | 30 | 13.1 | 2.3 | 35.0 | 50.4 | 132.5 | 0.008 |
| category | parameter | value | evidence | rationale | |
|---|---|---|---|---|---|
| 0 | scale_regime | scale_regime | hyperscale (Hyperscale Fleet (25,000+ series)) | n_series=100000, n_rows=146000000 | Hyperscale distributed portfolio (Spark Server... |
| 1 | models | naive_seasonal | include (statistical) | freq=D, median_acf=0.19 | Establishes the zero-skill seasonal benchmark ... |
| 2 | models | theta | include (statistical) | tier=deep_sky | Fast statistical baseline for trend + seasonal... |
| 3 | models | fft | include (statistical) | tier=deep_sky | Fast Fourier harmonic decomposition. |
| 4 | scale_guardrail | autoets, stl_bagging | pruned_for_scale | n_series=100000, scale_regime='hyperscale' | Skipped slow O(T^2) per-series state-space fit... |
| 5 | models | naive_mean | include (statistical) | sparse | Level anchor for sparse demand. |
| 6 | models | croston@classic | include (statistical) | sparse | Classic Croston estimator. |
| 7 | models | croston@sba | include (statistical) | sparse | SBA intermittent estimator. |
| 8 | models | croston@tsb | include (statistical) | sparse | TSB intermittent estimator. |
| 9 | models | lightgbm | include (ml) | tier=deep_sky | Gradient boosted trees across lags and covaria... |
| 10 | models | xgboost | include (ml) | tier=deep_sky | Regularized gradient boosted trees across lags... |
| 11 | models | catboost | include (ml) | tier=deep_sky | Symmetric oblivious trees resistant to covaria... |
| 12 | models | regression_lags | include (ml) | tier=deep_sky | Penalized ridge lag model for clean elasticity. |
| 13 | models | tide@global | include (deep_learning) | tier=deep_sky | Time-series Dense Encoder (TiDE) for global no... |
| 14 | models | tsmixer@global | include (deep_learning) | tier=deep_sky | All-MLP time- and feature-mixing neural archit... |
| 15 | models | chronos_bolt@global | include (deep_learning) | tier=deep_sky | Zero-shot univariate foundation model baseline. |
| 16 | features | features.outlier_policy | stl_resid | outlier_spike_share=36.0% | Isolated >4.5-MAD historical spikes detected; ... |
| 17 | features | features.regime_routing | True | regimes={'smooth': 0.74, 'erratic': 0.0333, 'i... | Panel mixes heterogeneous Syntetos-Boylan-Cros... |
| 18 | output | output.floor | 0.0 | min(y) >= 0.0 across 100% of historical observ... | Enforces physical non-negativity on point fore... |
| 19 | backtest | backtest.decision_metric | mase | goal='accuracy', intermittent=True | Optimizes model selection and ensemble weights... |
| 20 | baseline_ladder | baselines | naive_seasonal (naive_anchor), theta (plain_un... | 4-anchor baseline ladder (naive, plain univari... | Guarantees protected baseline anchors across p... |
| 21 | features | features.future_covariates | is_holiday | 1 known future driver(s) detected | Registers known future drivers for elastic and... |
| family | runtime | mode | hardware | n_models | n_borrowed | n_executed | parallel_slots | provision_p50_s | io_s | exec_p50_s | total_p50_s | total_p90_s | estimated_usd | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | statistical | spark | serverless | cpu | 7 | 0 | 7 | 64 | 64.4 | 1248.6 | 4050.0 | 5363.0 | 9103.5 | 5.005 |
| 1 | ml | spark | serverless | cpu | 8 | 0 | 8 | 64 | 64.4 | 1259.8 | 35338.5 | 36662.7 | 64663.7 | 34.218 |
| 2 | deep_learning | vertex | custom_job | gpu | 3 | 0 | 3 | 16 | 196.4 | 1203.8 | 9910.4 | 11310.6 | 20573.2 | 31.418 |
--- 3a. Online Adaptive Conformal Inference (forecaster.aci_df) ---
| ts_id | model_type | ds | step_idx | fold_id | horizon_step | y_true | yhat | abs_error | volatility_scale | ... | covered_aci | static_coverage | aci_coverage | rolling_coverage_split | rolling_coverage_aci | target_coverage | static_width | aci_width | interval_width_ratio | drift_detected | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | s_000000 | arima_plus | 2024-11-05 | 0 | 0 | 1 | 134.324 | 125.520307 | 8.803693 | 1.0 | ... | True | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 0.8 | 23.510354 | 23.510354 | 1.0 | False |
| 1 | s_000000 | arima_plus | 2024-11-06 | 1 | 0 | 2 | 103.581 | 104.982507 | 1.401507 | 1.0 | ... | True | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 0.8 | 23.510354 | 23.510354 | 1.0 | False |
| 2 | s_000000 | arima_plus | 2024-11-07 | 2 | 0 | 3 | 98.791 | 114.736561 | 15.945561 | 1.0 | ... | False | 0.666667 | 0.666667 | 0.666667 | 0.666667 | 0.8 | 23.510354 | 23.510354 | 1.0 | False |
| 3 | s_000000 | arima_plus | 2024-11-08 | 3 | 0 | 4 | 147.233 | 154.490327 | 7.257327 | 1.0 | ... | True | 0.750000 | 0.750000 | 0.750000 | 0.750000 | 0.8 | 23.510354 | 23.510354 | 1.0 | False |
| 4 | s_000000 | arima_plus | 2024-11-09 | 4 | 0 | 5 | 178.832 | 178.094313 | 0.737687 | 1.0 | ... | True | 0.800000 | 0.800000 | 0.800000 | 0.800000 | 0.8 | 23.510354 | 23.510354 | 1.0 | False |
| 5 | s_000000 | arima_plus | 2024-11-10 | 5 | 0 | 6 | 196.080 | 197.203052 | 1.123052 | 1.0 | ... | True | 0.833333 | 0.833333 | 0.833333 | 0.833333 | 0.8 | 23.510354 | 23.510354 | 1.0 | False |
6 rows × 34 columns
--- 3b. Joint Copula Trajectories & Portfolio VaR / CVaR Tail Risk ---
| ts_id | model_type | copula_type | n_paths | horizon | window | expected_cumulative_demand | std_cumulative_demand | iid_std_cumulative_demand | copula_amplification_ratio | ... | cvar_alpha | peak_window_mean | peak_window_var | peak_window_cvar | exceedance_prob | expected_shortfall_units | crps | energy_score | variogram_score | risk_verdict | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | s_000000 | arima_plus | student_t | 200 | 28 | 7 | 6238.353981 | 48.256076 | 34.297647 | 1.406979 | ... | 6368.162568 | 1674.494199 | 1709.654314 | 1730.014238 | 0.1 | 4.356466 | 1.212383 | 7.949952 | 0.075682 | amplified_tail_risk |
| 1 | s_000001 | arima_plus | student_t | 200 | 28 | 7 | 69.214307 | 28.464294 | 20.777342 | 1.369968 | ... | 145.614222 | 32.488310 | 53.683090 | 75.754775 | 0.1 | 2.725553 | 0.705201 | 4.640418 | 3.007648 | amplified_tail_risk |
| 2 | s_000002 | arima_plus | student_t | 200 | 28 | 7 | 5136.073759 | 41.231767 | 36.060895 | 1.143393 | ... | 5231.189234 | 1318.978916 | 1358.306202 | 1382.180312 | 0.1 | 2.847643 | 1.283061 | 8.446359 | 0.240388 | moderate_tail_risk |
| 3 | s_000003 | arima_plus | student_t | 200 | 28 | 7 | 2462.909987 | 42.132450 | 31.411789 | 1.341294 | ... | 2572.489580 | 666.250045 | 700.139669 | 723.109019 | 0.1 | 3.520768 | 1.084660 | 7.176843 | 0.323482 | amplified_tail_risk |
| 4 | s_000004 | arima_plus | student_t | 200 | 28 | 7 | 1590.551830 | 290.448350 | 221.562210 | 1.310911 | ... | 2341.155650 | 551.741289 | 779.527514 | 989.670489 | 0.1 | 25.810608 | 7.317958 | 48.278664 | 24.031731 | amplified_tail_risk |
| 5 | s_000005 | arima_plus | student_t | 200 | 28 | 7 | 7347.660765 | 33.465912 | 23.075485 | 1.450280 | ... | 7433.553387 | 1932.352070 | 1955.312642 | 1967.045192 | 0.1 | 2.945849 | 0.799786 | 5.255885 | 0.016135 | amplified_tail_risk |
6 rows × 27 columns
--- 3c. Portfolio-Constrained Multi-SKU Inventory Replenishment ---
| ts_id | model_type | policy_type | target_mode | lead_time | lead_time_std | review_period | protection_steps | mean_step_demand | lead_time_demand | ... | order_cost | order_spend | order_volume | allocation_ratio | shadow_price_budget | shadow_price_volume | shadow_price_units | portfolio_fill_rate | binding_constraint | uncertainty_source | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | s_000000 | arima_plus | continuous_s_S | cycle_service_level | 7.0 | 0.0 | 0.0 | 7.0 | 211.479274 | 1480.354921 | ... | 574.802752 | 574.802752 | 57.480275 | 0.038012 | 0.137875 | 0.0 | 0.0 | 0.959433 | budget+fill_rate | copula |
| 1 | s_000000 | chronos_bolt | continuous_s_S | cycle_service_level | 7.0 | 0.0 | 0.0 | 7.0 | 206.526402 | 1445.684817 | ... | 561.340796 | 561.340796 | 56.134080 | 0.035116 | 0.137875 | 0.0 | 0.0 | 0.959433 | budget+fill_rate | copula |
| 2 | s_000000 | ensemble_champion | continuous_s_S | cycle_service_level | 7.0 | 0.0 | 0.0 | 7.0 | 211.479274 | 1480.354921 | ... | 574.802752 | 574.802752 | 57.480275 | 0.035311 | 0.137875 | 0.0 | 0.0 | 0.959433 | budget+fill_rate | copula |
| 3 | s_000000 | ensemble_inverse_error | continuous_s_S | cycle_service_level | 7.0 | 0.0 | 0.0 | 7.0 | 211.294608 | 1479.062258 | ... | 574.300827 | 574.300827 | 57.430083 | 0.036490 | 0.137875 | 0.0 | 0.0 | 0.959433 | budget+fill_rate | copula |
| 4 | s_000000 | ensemble_mean | continuous_s_S | cycle_service_level | 7.0 | 0.0 | 0.0 | 7.0 | 210.628341 | 1474.398389 | ... | 572.489907 | 572.489907 | 57.248991 | 0.036096 | 0.137875 | 0.0 | 0.0 | 0.959433 | budget+fill_rate | copula |
| 5 | s_000000 | ensemble_nnls | continuous_s_S | cycle_service_level | 7.0 | 0.0 | 0.0 | 7.0 | 212.572735 | 1488.009142 | ... | 577.774787 | 577.774787 | 57.777479 | 0.036771 | 0.137875 | 0.0 | 0.0 | 0.959433 | budget+fill_rate | copula |
| 6 | s_000000 | ensemble_ridge | continuous_s_S | cycle_service_level | 7.0 | 0.0 | 0.0 | 7.0 | 213.882533 | 1497.177732 | ... | 581.334832 | 581.334832 | 58.133483 | 0.036751 | 0.137875 | 0.0 | 0.0 | 0.959433 | budget+fill_rate | copula |
| 7 | s_000000 | holtwinters | continuous_s_S | cycle_service_level | 7.0 | 0.0 | 0.0 | 7.0 | 211.275460 | 1478.928217 | ... | 574.248780 | 574.248780 | 57.424878 | 0.035783 | 0.137875 | 0.0 | 0.0 | 0.959433 | budget+fill_rate | copula |
8 rows × 47 columns
--- 3d. Prescriptive Price & Promotional Calendar Optimization (CVaR Risk-Adjusted Profit) ---
| ts_id | model_type | ds | forecast_date | horizon_step | baseline_price | optimal_price | price | price_change_pct | baseline_promo | ... | margin_pct | baseline_reorder_point | optimal_reorder_point | delta_reorder_point | baseline_safety_stock | optimal_safety_stock | delta_safety_stock | baseline_order_qty | optimal_order_qty | delta_order_qty | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | s_000000 | ensemble_champion | 2024-12-31 | 2024-12-31 | 1 | 10.0 | 10.6 | 10.6 | 6.0 | 0.0 | ... | 0.575472 | 1568.56758 | 1502.030623 | -66.536957 | 88.212659 | 85.647328 | -2.56533 | 1568.56758 | 1502.030623 | -66.536957 |
| 1 | s_000000 | ensemble_champion | 2025-01-01 | 2025-01-01 | 2 | 10.0 | 10.6 | 10.6 | 6.0 | 0.0 | ... | 0.575472 | 1568.56758 | 1502.030623 | -66.536957 | 88.212659 | 85.647328 | -2.56533 | 1568.56758 | 1502.030623 | -66.536957 |
| 2 | s_000000 | ensemble_champion | 2025-01-02 | 2025-01-02 | 3 | 10.0 | 10.6 | 10.6 | 6.0 | 0.0 | ... | 0.575472 | 1568.56758 | 1502.030623 | -66.536957 | 88.212659 | 85.647328 | -2.56533 | 1568.56758 | 1502.030623 | -66.536957 |
| 3 | s_000000 | ensemble_champion | 2025-01-03 | 2025-01-03 | 4 | 10.0 | 10.4 | 10.4 | 4.0 | 0.0 | ... | 0.567308 | 1568.56758 | 1502.030623 | -66.536957 | 88.212659 | 85.647328 | -2.56533 | 1568.56758 | 1502.030623 | -66.536957 |
| 4 | s_000000 | ensemble_champion | 2025-01-04 | 2025-01-04 | 5 | 10.0 | 10.6 | 10.6 | 6.0 | 0.0 | ... | 0.575472 | 1568.56758 | 1502.030623 | -66.536957 | 88.212659 | 85.647328 | -2.56533 | 1568.56758 | 1502.030623 | -66.536957 |
| 5 | s_000000 | ensemble_champion | 2025-01-05 | 2025-01-05 | 6 | 10.0 | 10.6 | 10.6 | 6.0 | 0.0 | ... | 0.575472 | 1568.56758 | 1502.030623 | -66.536957 | 88.212659 | 85.647328 | -2.56533 | 1568.56758 | 1502.030623 | -66.536957 |
| 6 | s_000000 | ensemble_champion | 2025-01-06 | 2025-01-06 | 7 | 10.0 | 10.6 | 10.6 | 6.0 | 0.0 | ... | 0.575472 | 1568.56758 | 1502.030623 | -66.536957 | 88.212659 | 85.647328 | -2.56533 | 1568.56758 | 1502.030623 | -66.536957 |
| 7 | s_000000 | ensemble_champion | 2025-01-07 | 2025-01-07 | 8 | 10.0 | 10.6 | 10.6 | 6.0 | 0.0 | ... | 0.575472 | 1568.56758 | 1502.030623 | -66.536957 | 88.212659 | 85.647328 | -2.56533 | 1568.56758 | 1502.030623 | -66.536957 |
8 rows × 47 columns
Act 6 · Lifecycle Markdown, Contract Volume, Assortment Rationalization, Pre-Pack Allocation & Lateral Rebalancing (Track Q / R)¶
Once the multi-engine DAG finishes (or on any completed run_id), supply-chain and merchandising teams can invoke the Track Q / R prescriptive solvers directly on the Forecaster instance:
- Lifecycle Markdown & Space Reclamation MILP (
forecaster.optimize_clearance): Computes the profit-maximizing monotone discount ladder ($d_{i,t} \le d_{i,t+1}$) withTrack Pdigital-twin deep-discount elasticity borrowing (elasticity_source) and physical warehouse/shelf volume reclamation (target_space_freed). - Vendor Contract Volume & Tiered Rebate / Take-or-Pay Optimization (
forecaster.optimize_contract_volume): Allocates promotional discounts across SKUs to unlock retroactive all-units rebate tiers or satisfy Take-or-Pay minimum volume commitments under Copula $\text{CVaR}_{\alpha}$ tail shortfall buffering. - Assortment Delisting Transference, Simplex Size-Curve Pre-Packs & Lateral Store Rebalancing (
forecaster.optimize_assortment,forecaster.optimize_prepacks,forecaster.optimize_rebalancing): Rationalizes SKU assortments with similarity/Halo walk-rate transference, allocates integer pre-pack bundles against Empirical-Bayes CLR size curves, and solves Hitchcock–Koopmans lateral transshipment across stores.
print("--- 6a. Lifecycle Markdown, Digital-Twin Elasticity Borrowing & Space Reclamation ---")
clearance_cloud = forecaster.optimize_clearance(
initial_inventory=1600.0,
expiry_step=10,
unit_volume=1.5,
target_space_freed=12000.0,
reclaim_by_step=10,
spoilage_cost=3.0,
salvage_value=1.0,
)
print(
f"Clearance Status: {clearance_cloud.status} (is_feasible={clearance_cloud.is_feasible}) | "
f"Net Profit: ${clearance_cloud.total_optimal_profit:,.2f} (Lift: +${clearance_cloud.total_profit_lift:,.2f}) | "
f"Space Freed: {clearance_cloud.total_space_freed:,.1f} / {clearance_cloud.target_space_freed:,.1f}"
)
display(
clearance_cloud.summary_df[
[
"ts_id",
"initial_inventory",
"optimal_sell_through_units",
"sell_through_pct",
"total_space_freed",
"max_discount_pct",
"price_elasticity",
"elasticity_source",
"optimal_gross_profit",
"net_profit_lift",
]
].head(8)
)
print("\n--- 6b. Vendor Contract Volume & Tiered Rebate / Take-or-Pay Optimization ---")
contract_cloud = forecaster.optimize_contract_volume(
contract_tiers=[(15000.0, 25000.0), (22000.0, 65000.0)],
min_contract_volume=18000.0,
shortfall_penalty_per_unit=5.0,
risk_aversion_lambda=0.5,
)
print(
f"Contract Status: {contract_cloud.status} | "
f"Volume: {contract_cloud.optimal_portfolio_units:,.1f} (CVaR Shortfall: {contract_cloud.cvar_shortfall_units:,.1f}) | "
f"Rebate Tier Reached: {contract_cloud.achieved_tier_units:,.0f} units (${contract_cloud.rebate_earned:,.2f}) | "
f"Net Value Lift: +${contract_cloud.net_value_lift:,.2f}"
)
display(contract_cloud.summary_df.head(8))
print("\n--- 6c. Assortment Delisting, Simplex Pre-Packs & Lateral Store Rebalancing (Track Q.2 / R.2) ---")
as_08 = forecaster.optimize_assortment(max_skus=4)
pp_08 = forecaster.optimize_prepacks(sizes=["S", "M", "L", "XL"], pack_size=6)
rb_08 = forecaster.optimize_rebalancing(safety_stock="auto")
print(
f"Assortment Rationalization (Track Q.2): Retained {as_08.retained_skus}/{as_08.total_candidate_skus} SKUs | "
f"Transferred: {as_08.transferred_units:,.1f}u | Category Retention: {as_08.category_retention_pct:.1%}"
)
print(
f"Integer Pre-Pack MILP (Track R.2): {pp_08.total_allocated_units:,.0f}u allocated | "
f"Fill Rate: {pp_08.fill_rate_pct:.1%} | Overstock: {pp_08.total_overstock_units:,.1f}u"
)
print(
f"Lateral Store Rebalancing (Track R.2): Transferred {rb_08.total_transferred_units:,.1f}u | "
f"Net Cost Savings: +${rb_08.net_cost_savings:,.2f}"
)
--- 6a. Lifecycle Markdown, Digital-Twin Elasticity Borrowing & Space Reclamation ---
Clearance Status: optimal (is_feasible=True) | Net Profit: $129,440.98 (Lift: +$5,356.52) | Space Freed: 24,458.7 / 12,000.0
| ts_id | initial_inventory | optimal_sell_through_units | sell_through_pct | total_space_freed | max_discount_pct | price_elasticity | elasticity_source | optimal_gross_profit | net_profit_lift | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | s_000000 | 1600.0 | 1600.000000 | 1.000000 | 2400.000000 | 0.0 | -1.8 | prior_default | 19200.000000 | 0.000000 |
| 1 | s_000001 | 1600.0 | 46.372538 | 0.028983 | 69.558807 | 0.3 | -1.8 | prior_default | -2832.314057 | 26.048571 |
| 2 | s_000002 | 1600.0 | 1600.000000 | 1.000000 | 2400.000000 | 0.0 | -1.8 | prior_default | 19200.000000 | 0.000000 |
| 3 | s_000003 | 1600.0 | 1563.489775 | 0.977181 | 2345.234663 | 0.3 | -1.8 | prior_default | 9196.846024 | 878.249841 |
| 4 | s_000004 | 1600.0 | 1049.302414 | 0.655814 | 1573.953620 | 0.3 | -1.8 | prior_default | 5119.875614 | 589.418423 |
| 5 | s_000005 | 1600.0 | 1600.000000 | 1.000000 | 2400.000000 | 0.0 | -1.8 | prior_default | 19200.000000 | 0.000000 |
| 6 | s_000006 | 1600.0 | 24.999899 | 0.015625 | 37.499848 | 0.3 | -1.8 | prior_default | -3001.776834 | 14.043045 |
| 7 | s_000007 | 1600.0 | 1584.861741 | 0.990539 | 2377.292612 | 0.1 | -1.8 | prior_default | 18593.278084 | 73.886927 |
--- 6b. Vendor Contract Volume & Tiered Rebate / Take-or-Pay Optimization ---
Contract Status: optimal | Volume: 49,325.5 (CVaR Shortfall: 0.0) | Rebate Tier Reached: 22,000 units ($65,000.00) | Net Value Lift: +$3,601.05
| ts_id | baseline_units | optimal_units | incremental_units | mean_discount_pct | max_discount_pct | baseline_margin | optimal_margin | rebate_allocated | shortfall_penalty_allocated | net_contract_value | price_elasticity | elasticity_source | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | s_000000 | 6236.711205 | 7539.093288 | 1302.382083 | 0.1 | 0.1 | 74840.534464 | 75390.932879 | 9934.850949 | 0.0 | 85325.783828 | -1.8 | prior_default |
| 1 | s_000001 | 68.327474 | 82.595969 | 14.268494 | 0.1 | 0.1 | 819.929693 | 825.959688 | 108.843147 | 0.0 | 934.802835 | -1.8 | prior_default |
| 2 | s_000002 | 5135.938717 | 6208.451832 | 1072.513115 | 0.1 | 0.1 | 61631.264607 | 62084.518323 | 8181.360971 | 0.0 | 70265.879293 | -1.8 | prior_default |
| 3 | s_000003 | 2460.823128 | 2974.704859 | 513.881731 | 0.1 | 0.1 | 29529.877534 | 29747.048589 | 3920.000491 | 0.0 | 33667.049080 | -1.8 | prior_default |
| 4 | s_000004 | 1582.341423 | 1912.774090 | 330.432667 | 0.1 | 0.1 | 18988.097079 | 19127.740904 | 2520.611533 | 0.0 | 21648.352437 | -1.8 | prior_default |
| 5 | s_000005 | 7346.741709 | 8880.926066 | 1534.184357 | 0.1 | 0.1 | 88160.900514 | 88809.260661 | 11703.088606 | 0.0 | 100512.349267 | -1.8 | prior_default |
| 6 | s_000006 | 36.836024 | 44.528312 | 7.692288 | 0.1 | 0.1 | 442.032292 | 445.283122 | 58.678428 | 0.0 | 503.961550 | -1.8 | prior_default |
| 7 | s_000007 | 4531.166341 | 5477.387780 | 946.221440 | 0.1 | 0.1 | 54373.996088 | 54773.877803 | 7217.980878 | 0.0 | 61991.858681 | -1.8 | prior_default |
--- 6c. Assortment Delisting, Simplex Pre-Packs & Lateral Store Rebalancing (Track Q.2 / R.2) --- Assortment Rationalization (Track Q.2): Retained 4/15 SKUs | Transferred: 5,765.2u | Category Retention: 71.0% Integer Pre-Pack MILP (Track R.2): 41,166u allocated | Fill Rate: 100.0% | Overstock: 27.2u Lateral Store Rebalancing (Track R.2): Transferred 8,247.7u | Net Cost Savings: +$185,573.91
Where next¶
- Next in Track 4 (Master Workflow & Operations):
10_registry_operations_and_scale.ipynb— Day-2 registry health (doctor), safe repair (retry), all 5 launch pathways (including Cloud Composer 3 DAGs), and cross-platform run review. - Glass-Box Auto-Forecaster & Bounded
autofocus:11_auto_forecaster_and_autofocus.ipynb— zero-configuration exposure tiers (first_lightthroughdeep_field), closed-loopautofocus, and the 12-panel DGP benchmark bank. - Extend the platform:
09_custom_models_and_metrics.ipynb— add custom 1-file models and metrics. - Documentation: Glass-Box Auto-Forecaster · Choosing a runtime · Cost estimates & controls · Validation ledger