Model Playground¶
playground
¶
Local model-dev loop — try any model on sample data, offline.
This is the on-ramp for a data scientist opening the repo: pick a model, get a small
sample dataset, run the real worker cell, and read the prediction frame + metric panel —
no GCP, no config files. The notebook (notebooks/00_model_playground.ipynb) and the CLI
(python -m scale_forecasting.playground) are both thin skins over the functions here,
so the dev loop and production run the identical code path: sample → validate →
worker.run_cell.
Adding a model needs no change here — available_models reads the factory registry,
so a new file under models/ that ends in register(...) appears automatically.
Public surface: available_models, model_catalog, metric_catalog, sample_data,
build_config, run_model, summarize.
BakeOff
dataclass
¶
Bases: PlaygroundWorkbenchMixin
A local multi-model bake-off on one series: the leaderboard + everything to plot it.
leaderboard is one row per model — base models and the ensemble pseudo-models —
ranked by the decision metric. predictions is the long-format future forecast for
every model (base + ensemble) so the notebook can overlay them. series is the history
they were fit on; config is the frozen RunConfig that drove the whole thing; oof
holds the combined base + ensemble out-of-fold rows for FVA, horizon-decay, and bias audits.
aci_df
¶
aci_df(
*,
actuals_df=None,
target_coverage=0.8,
target_alpha=None,
gamma=None,
normalized=True,
method=None,
horizon_delay=True,
window=None,
model_type=None,
return_result=False,
)
Compute Adaptive Conformal Inference (ACI) online coverage tracking (aci).
Source code in src/scale_forecasting/playground.py
allocate_target
¶
allocate_target(
target_total=None,
*,
target=None,
targets=None,
target_sum=None,
model_type=None,
locked_nodes=None,
locks=None,
lower_bounds=None,
upper_bounds=None,
bounds=None,
floor=0.0,
cap=None,
method="mint_shrink",
weights=None,
smoothness_weight=0.0,
price_col=None,
prices=None,
unit_cost=None,
include_inventory_impact=False,
lead_time=7.0,
lead_time_std=0.0,
service_level=0.95,
inventory_params=None,
)
Allocate a top-down target across this bake-off's forecasts
(goal_seek.allocate_target).
Source code in src/scale_forecasting/playground.py
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 | |
bias_df
¶
bias_report_df
¶
Audit each bake-off model for directional bias and Trigg Tracking Signal.
Source code in src/scale_forecasting/playground.py
cold_start_transfer_df
¶
cold_start_transfer_df(
*,
min_obs=None,
min_history_points=14,
method=None,
matching=None,
cold_start_matching=None,
similarity_method=None,
text_cols=None,
attribute_cols=None,
hierarchy_cols=None,
top_k_donors=3,
donor_pool_df=None,
model_type=None,
return_result=False,
**kwargs,
)
Synthesize cold-start / NPI trajectories via analog donor matching (cold_start).
Source code in src/scale_forecasting/playground.py
exceptions_df
¶
Build the Top-N exception triage queue across all models in this bake-off.
Source code in src/scale_forecasting/playground.py
export_report
¶
export_report(
out_path,
*,
title=None,
goal_seek_df=None,
aci_df=None,
tail_risk_df=None,
cold_start_df=None,
inventory_opt_df=None,
scenario_opt_df=None,
similarity_df=None,
similarity_clusters_df=None,
substitutes_df=None,
emerging_trends_df=None,
write_json=False,
include_json_sidecar=False,
)
Export a self-contained interactive .html report for this bake-off.
Source code in src/scale_forecasting/playground.py
fva_df
¶
Compute Forecast Value Added (FVA) and Diebold–Mariano p-values across models.
Source code in src/scale_forecasting/playground.py
horizon_decay_df
¶
Compute lead-time accuracy decay by horizon step across all bake-off models.
Source code in src/scale_forecasting/playground.py
inventory_policy_df
¶
inventory_policy_df(
*,
inventory_df=None,
model_name=None,
model_type=None,
lead_time=7.0,
lead_time_std=0.0,
review_period=0.0,
service_level=0.95,
fill_rate=None,
on_hand=0.0,
on_order=0.0,
backorders=0.0,
holding_cost=1.0,
stockout_cost=9.0,
min_order_qty=0.0,
order_multiple=0.0,
max_budget=None,
max_volume=None,
max_total_units=None,
target_portfolio_fill_rate=None,
unit_cost=1.0,
unit_volume=1.0,
vendor_moq=None,
uncertainty_source="ar1",
trajectories_df=None,
copula_paths=None,
copula_type="gaussian",
n_paths=300,
seed=42,
)
Translate bake-off forecasts across all models into operational inventory policies.
Source code in src/scale_forecasting/playground.py
1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 | |
optimize_inventory_df
¶
optimize_inventory_df(
*,
inventory_df=None,
trajectories_df=None,
copula_paths=None,
model_name=None,
model_type=None,
lead_time=7.0,
lead_time_std=0.0,
review_period=0.0,
service_level=0.95,
fill_rate=None,
target_portfolio_fill_rate=None,
min_portfolio_fill_rate=None,
max_budget=None,
max_volume=None,
max_total_units=None,
holding_cost=1.0,
stockout_cost=9.0,
unit_cost=10.0,
unit_volume=1.0,
min_order_qty=0.0,
order_multiple=None,
vendor_moq=None,
on_hand=0.0,
on_order=0.0,
backorders=0.0,
uncertainty_source="copula",
copula_type="auto",
similarity_shrinkage=True,
similarity_pooling=None,
similarity_weight="auto",
similarity_matrix=None,
similarity_df=None,
similarity_method="hybrid",
n_paths=300,
seed=42,
return_result=False,
)
Solve portfolio-constrained inventory replenishment (inventory_optimizer).
Source code in src/scale_forecasting/playground.py
1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 | |
optimize_scenario
¶
optimize_scenario(
*,
future_covariates_df=None,
trajectories_df=None,
objective="gross_profit",
price_col=None,
promo_col=None,
price_bounds=(-0.15, 0.15),
price_grid=None,
promo_bounds=(0.0, 1.0),
binary_promo=True,
max_promo_days=None,
max_promo_periods=None,
min_cooldown_days=0,
min_promo_gap=0,
min_margin_pct=None,
min_gross_margin=None,
min_total_units=None,
max_total_units=None,
target_total_units=None,
max_promo_budget=None,
inventory_cap=None,
unit_cost=4.0,
promo_fixed_cost=0.0,
risk_aversion_lambda=0.0,
cvar_alpha=0.95,
pull_forward_lags=3,
cannibalization_weight=1.0,
cannibalization_strength=None,
use_similarity_priors=True,
cross_sku_elasticity=None,
similarity_cannibalization=None,
similarity_matrix=None,
similarity_df=None,
similarity_method="hybrid",
reconcile=True,
include_inventory_impact=True,
lead_time=7.0,
lead_time_std=0.0,
service_level=0.95,
n_paths=250,
copula_type="auto",
seed=42,
model_type=None,
**_kwargs,
)
Solve prescriptive price & promotional calendar optimization (scenario_optimizer).
Source code in src/scale_forecasting/playground.py
1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 | |
plot_inventory_policy
¶
plot_inventory_policy(
*,
inventory_df=None,
model_name=None,
model_type=None,
lead_time=7.0,
lead_time_std=0.0,
review_period=0.0,
service_level=0.95,
fill_rate=None,
on_hand=0.0,
on_order=0.0,
backorders=0.0,
holding_cost=1.0,
stockout_cost=9.0,
min_order_qty=0.0,
order_multiple=0.0,
max_budget=None,
max_volume=None,
max_total_units=None,
target_portfolio_fill_rate=None,
unit_cost=1.0,
unit_volume=1.0,
vendor_moq=None,
uncertainty_source="ar1",
trajectories_df=None,
copula_paths=None,
copula_type="gaussian",
n_paths=300,
seed=42,
max_rows=15,
ax=None,
title=None,
)
Plot Reorder Points (ROP), Safety Stock (SS), and Order Quantities across models.
Source code in src/scale_forecasting/playground.py
1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 | |
plot_promo_elasticity
¶
Plot organic baseline vs. promotional lift and post-promo dip for this bake-off.
Source code in src/scale_forecasting/playground.py
promo_elasticity_df
¶
promo_elasticity_df(
*,
promo_col=None,
price_col=None,
confounders=None,
summary=False,
use_similarity_priors=True,
similarity_pooling=None,
similarity_weight=None,
similarity_matrix=None,
similarity_df=None,
similarity_method="hybrid",
pooling_strength=0.5,
)
Compute cross-fitted Double-ML promo & price elasticity decomposition on this bake-off's series.
Source code in src/scale_forecasting/playground.py
rollup_time
¶
Aggregate bake-off future predictions to coarser calendar periods with AR(1) bounds.
Source code in src/scale_forecasting/playground.py
sample_coherent_paths
¶
sample_coherent_paths(
*,
model_type=None,
n_paths=200,
seed=42,
method="mint_shrink",
nonneg=False,
)
Draw n_paths coherent probabilistic trajectory scenarios for this bake-off.
Source code in src/scale_forecasting/playground.py
sample_trajectories
¶
sample_trajectories(
*,
n_paths=500,
copula_type="auto",
df_t=4.0,
cross_series=True,
similarity_shrinkage=True,
similarity_weight="auto",
similarity_matrix=None,
similarity_df=None,
similarity_method="hybrid",
reconcile=True,
reconcile_hierarchy=True,
floor=None,
cap=None,
seed=42,
nonneg=False,
model_type=None,
return_result=False,
**_kwargs,
)
Generate joint copula trajectory paths (copula.sample_trajectories).
Source code in src/scale_forecasting/playground.py
simulate_scenarios
¶
simulate_scenarios(
scenarios,
*,
models=None,
price_col=None,
unit_cost=None,
reconcile=True,
include_inventory_impact=False,
lead_time=7.0,
lead_time_std=0.0,
service_level=0.95,
inventory_params=None,
)
Run counterfactual covariate scenarios across this bake-off's series and models.
Source code in src/scale_forecasting/playground.py
tail_risk_df
¶
tail_risk_df(
trajectories_df=None,
*,
actuals_df=None,
lead_time=None,
window=7,
alphas=(0.9, 0.95, 0.99),
alpha=0.95,
threshold=None,
holding_cost=None,
stockout_cost=None,
n_paths=300,
copula_type="auto",
similarity_shrinkage=False,
similarity_df=None,
seed=42,
model_type=None,
**_kwargs,
)
Compute VaR and CVaR tail-risk summary (copula.compute_tail_risk).
Source code in src/scale_forecasting/playground.py
temporal_reconcile_df
¶
temporal_reconcile_df(
*,
method="mint_shrink",
model_type=None,
aggregations=None,
temporal_aggregations=None,
)
Reconcile bake-off forecasts across temporal aggregations (THieF).
Source code in src/scale_forecasting/playground.py
PlaygroundRun
dataclass
¶
Bases: PlaygroundWorkbenchMixin
One model run on one series — the CellResult plus the series it ran on.
aci_df
¶
aci_df(
*,
actuals_df=None,
target_coverage=0.8,
target_alpha=None,
gamma=0.05,
normalized=True,
method="aci_normalized",
horizon_delay=True,
window=None,
return_result=False,
)
Compute Adaptive Conformal Inference (ACI) online coverage tracking (aci).
Source code in src/scale_forecasting/playground.py
allocate_target
¶
allocate_target(
target_total=None,
*,
target=None,
targets=None,
target_sum=None,
locked_nodes=None,
locks=None,
lower_bounds=None,
upper_bounds=None,
bounds=None,
floor=0.0,
cap=None,
method="mint_shrink",
weights=None,
smoothness_weight=0.0,
price_col=None,
prices=None,
unit_cost=None,
include_inventory_impact=False,
lead_time=7.0,
lead_time_std=0.0,
service_level=0.95,
inventory_params=None,
)
Allocate a top-down target across this series' forecast horizon
(goal_seek.allocate_target).
Source code in src/scale_forecasting/playground.py
bias_df
¶
bias_report_df
¶
Compute directional bias and Trigg Tracking Signal for this run's backtest OOF.
Source code in src/scale_forecasting/playground.py
cold_start_transfer_df
¶
cold_start_transfer_df(
*,
min_obs=None,
min_history_points=14,
method=None,
matching=None,
cold_start_matching=None,
similarity_method=None,
text_cols=None,
attribute_cols=None,
hierarchy_cols=None,
top_k_donors=3,
donor_pool_df=None,
return_result=False,
**kwargs,
)
Synthesize cold-start / NPI trajectories via analog donor matching (cold_start).
Source code in src/scale_forecasting/playground.py
exceptions_df
¶
Return the exception triage queue for this playground run.
Source code in src/scale_forecasting/playground.py
export_report
¶
export_report(
out_path,
*,
title=None,
goal_seek_df=None,
aci_df=None,
tail_risk_df=None,
cold_start_df=None,
inventory_opt_df=None,
scenario_opt_df=None,
similarity_df=None,
similarity_clusters_df=None,
substitutes_df=None,
emerging_trends_df=None,
write_json=False,
include_json_sidecar=False,
)
Export a self-contained .html report for this playground run.
Source code in src/scale_forecasting/playground.py
horizon_decay_df
¶
Compute lead-time error decay across horizon steps for this run's backtest OOF.
Source code in src/scale_forecasting/playground.py
inventory_policy_df
¶
inventory_policy_df(
*,
inventory_df=None,
lead_time=7.0,
lead_time_std=0.0,
review_period=0.0,
service_level=0.95,
fill_rate=None,
on_hand=0.0,
on_order=0.0,
backorders=0.0,
holding_cost=1.0,
stockout_cost=9.0,
min_order_qty=0.0,
order_multiple=0.0,
max_budget=None,
max_volume=None,
max_total_units=None,
target_portfolio_fill_rate=None,
unit_cost=1.0,
unit_volume=1.0,
vendor_moq=None,
uncertainty_source="ar1",
trajectories_df=None,
copula_paths=None,
copula_type="gaussian",
n_paths=300,
seed=42,
)
Translate this run's calibrated forecasts into an operational inventory policy.
Source code in src/scale_forecasting/playground.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | |
optimize_inventory_df
¶
optimize_inventory_df(
*,
inventory_df=None,
trajectories_df=None,
copula_paths=None,
lead_time=7.0,
lead_time_std=0.0,
review_period=0.0,
service_level=0.95,
fill_rate=None,
target_portfolio_fill_rate=None,
min_portfolio_fill_rate=None,
max_budget=None,
max_volume=None,
max_total_units=None,
holding_cost=1.0,
stockout_cost=9.0,
unit_cost=10.0,
unit_volume=1.0,
min_order_qty=0.0,
order_multiple=None,
vendor_moq=None,
on_hand=0.0,
on_order=0.0,
backorders=0.0,
uncertainty_source="copula",
copula_type="auto",
similarity_shrinkage=True,
similarity_pooling=None,
similarity_weight="auto",
similarity_matrix=None,
similarity_method="hybrid",
n_paths=300,
seed=42,
return_result=False,
)
Solve portfolio-constrained inventory replenishment (inventory_optimizer).
Source code in src/scale_forecasting/playground.py
941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | |
optimize_scenario
¶
optimize_scenario(
*,
future_covariates_df=None,
trajectories_df=None,
objective="gross_profit",
price_col=None,
promo_col=None,
price_bounds=(-0.15, 0.15),
price_grid=None,
promo_bounds=(0.0, 1.0),
binary_promo=True,
max_promo_days=None,
max_promo_periods=None,
min_cooldown_days=0,
min_promo_gap=0,
min_margin_pct=None,
min_gross_margin=None,
min_total_units=None,
max_total_units=None,
target_total_units=None,
max_promo_budget=None,
inventory_cap=None,
unit_cost=4.0,
promo_fixed_cost=0.0,
risk_aversion_lambda=0.0,
cvar_alpha=0.95,
pull_forward_lags=3,
cannibalization_weight=1.0,
cannibalization_strength=None,
use_similarity_priors=True,
cross_sku_elasticity=None,
similarity_matrix=None,
similarity_method="hybrid",
reconcile=True,
include_inventory_impact=True,
lead_time=7.0,
lead_time_std=0.0,
service_level=0.95,
n_paths=250,
copula_type="auto",
seed=42,
**_kwargs,
)
Solve prescriptive price & promotional calendar optimization (scenario_optimizer).
Source code in src/scale_forecasting/playground.py
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 | |
plot_inventory_policy
¶
plot_inventory_policy(
*,
inventory_df=None,
lead_time=7.0,
lead_time_std=0.0,
review_period=0.0,
service_level=0.95,
fill_rate=None,
on_hand=0.0,
on_order=0.0,
backorders=0.0,
holding_cost=1.0,
stockout_cost=9.0,
min_order_qty=0.0,
order_multiple=0.0,
max_budget=None,
max_volume=None,
max_total_units=None,
target_portfolio_fill_rate=None,
unit_cost=1.0,
unit_volume=1.0,
vendor_moq=None,
uncertainty_source="ar1",
trajectories_df=None,
copula_paths=None,
copula_type="gaussian",
n_paths=300,
seed=42,
ax=None,
title=None,
)
Plot Reorder Point (ROP), Safety Stock (SS), and Order Quantity for this run.
Source code in src/scale_forecasting/playground.py
plot_promo_elasticity
¶
Plot organic baseline vs. promotional lift and post-promo dip for this series.
Source code in src/scale_forecasting/playground.py
promo_elasticity_df
¶
promo_elasticity_df(
*,
promo_col=None,
price_col=None,
confounders=None,
summary=False,
use_similarity_priors=True,
similarity_pooling=None,
similarity_weight=None,
similarity_matrix=None,
similarity_method="hybrid",
)
Compute cross-fitted Double-ML promo & price elasticity decomposition on this series.
Source code in src/scale_forecasting/playground.py
rollup_time
¶
Aggregate this run's future predictions to coarser calendar buckets with AR(1) bounds.
Source code in src/scale_forecasting/playground.py
sample_coherent_paths
¶
Draw n_paths coherent probabilistic trajectory scenarios for this playground run.
Source code in src/scale_forecasting/playground.py
sample_trajectories
¶
sample_trajectories(
*,
n_paths=500,
copula_type="auto",
df_t=4.0,
cross_series=True,
reconcile=True,
similarity_shrinkage=True,
similarity_weight="auto",
similarity_matrix=None,
similarity_method="hybrid",
floor=None,
cap=None,
seed=42,
nonneg=False,
return_result=False,
**_kwargs,
)
Generate joint copula trajectory paths (copula.sample_trajectories).
Source code in src/scale_forecasting/playground.py
simulate_scenarios
¶
simulate_scenarios(
scenarios,
*,
price_col=None,
unit_cost=None,
reconcile=True,
include_inventory_impact=False,
lead_time=7.0,
lead_time_std=0.0,
service_level=0.95,
inventory_params=None,
)
Run counterfactual future covariate scenarios on this single-series run.
Source code in src/scale_forecasting/playground.py
tail_risk_df
¶
tail_risk_df(
trajectories_df=None,
*,
actuals_df=None,
lead_time=None,
window=7,
alphas=(0.9, 0.95, 0.99),
alpha=0.95,
threshold=None,
holding_cost=None,
stockout_cost=None,
n_paths=300,
copula_type="auto",
reconcile=True,
similarity_shrinkage=True,
similarity_weight="auto",
similarity_matrix=None,
similarity_method="hybrid",
seed=42,
**_kwargs,
)
Compute VaR and CVaR tail-risk summary (copula.compute_tail_risk).
Source code in src/scale_forecasting/playground.py
temporal_reconcile_df
¶
temporal_reconcile_df(
*,
method="mint_shrink",
aggregations=None,
temporal_aggregations=None,
stamp_method=False,
)
Reconcile this run's forecast across temporal aggregations (THieF).
Source code in src/scale_forecasting/playground.py
available_models
¶
Registered model names, sorted (the factory is the source of truth).
BigQuery-native models run as SQL in BigQuery, not in a local cell, so they're
excluded by default — the playground runs the Python models offline. Pass
installed_only=True to filter out models whose optional Python package is
not installed in the current environment.
Source code in src/scale_forecasting/playground.py
bakeoff
¶
bakeoff(
data=None,
*,
ts_id=None,
models=None,
freq="D",
horizon=28,
n_folds=3,
calculated="inverse_error",
learned="nnls",
with_exog=False,
future_covariates=None,
past_covariates=None,
static_covariates=None,
include_univariate_baselines=False,
ablation_modes=None,
ablation_models=None,
variant_policy="best_per_base_model",
model_params=None,
floor=None,
cap=None,
integer_rounding="none",
quantiles=None,
)
Run several models head-to-head on one series and add two ensembles — via the framework.
The playground's showcase of the whole pipeline offline: it runs every model in
models on one series with backtesting on (worker.run_cell, the same cell a
100k run executes), then builds one calculated and one learned ensemble by calling
the exact framework functions the real ensemble stage uses — no reimplementation:
- calculated (default
inverse_error):ensembler.combine_calculatedblends the base future forecasts, weighting by1/decision_metricfrom the backtest. - learned (default
nnls):ensembler.fit_learnedtrains the meta-learner on the base backtest OOF, thenensemble_run._apply_weightsapplies the weights. - scoring:
ensembler.combine_oof+metrics.compute_metrics/worker.rollup_metricsscore every ensemble on the OOF window — the identical pathensemble_run.run_ensemblesuses, minus the BigQuery I/O.
Because it drives real framework code, the leaderboard here is what a scaled run would
produce for the same series. models defaults to a fast, reliable subset; pass your own
(see available_models) to compare any Python models. Returns a BakeOff.
Source code in src/scale_forecasting/playground.py
2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 | |
build_config
¶
build_config(
model,
*,
freq="D",
horizon=28,
backtest=False,
with_exog=False,
static_covariates=None,
future_covariates=None,
past_covariates=None,
floor=None,
cap=None,
integer_rounding="none",
quantiles=None,
)
A minimal RunConfig for running model on sample_data.
Wires the generator's column names (ts_id/ds/y, and price_index as the
exog role when with_exog=True) so the config matches the sample panel out of the box.
backtest turns on a small 3-fold CV so the metric panel is populated (otherwise metrics
are NaN by design — full-fit runs don't score themselves).
Source code in src/scale_forecasting/playground.py
metric_catalog
¶
Every registered evaluation metric with its direction and input requirements.
Columns: metric, kind, direction, needs_intervals, needs_train_history,
needs_seasonal_period, mean_optimal.
Source code in src/scale_forecasting/playground.py
model_catalog
¶
Every registered model with the runtimes it can run on — the whole suite, one table.
One row per model (Python, Vertex AI AutoML, and BigQuery-native), so the story is
complete: which model runs where, what covariates it accepts, and whether it emits
two-tier feature attributions (explainability). The flags are derived from the model's
class metadata, not a hand-maintained list, so a new model file shows up here automatically:
- Python-runtime models run the identical cell code (
worker.run_cell) on every Python compute —local(this playground),spark(Dataproc fan-out),ray(Ray on Vertex or GKE),vertex(Vertex CustomJob),gce(GCE Single-VM), andgke(GKE Indexed Jobs). - Vertex AI AutoML models (
runtime == "vertex_automl") run global cross-series Tabular Workflows or AutoML training jobs in the cloud (engines/automl_engine) and also provide an offline panel ridge approximation for local sandbox testing. - BigQuery-native models run only as SQL in
bigquery(engines/bigquery_engine); they can't run in a local/Spark/Ray Python cell (their in-process fit/predict raise).
Columns: model, family, runtime, package, package_url, available, local, spark, ray, gpu,
vertex_automl, bigquery, exog, future_covariates, past_covariates, static_covariates,
explainability, monotonic_constraints, global_mode, hybrid_mode.
Source code in src/scale_forecasting/playground.py
run_model
¶
run_model(
model,
data=None,
*,
ts_id=None,
freq="D",
horizon=28,
backtest=False,
with_exog=False,
future_covariates=None,
floor=None,
cap=None,
integer_rounding="none",
quantiles=None,
)
Run one model on one series and return the result (validates first).
data defaults to a fresh sample_data panel (matching freq/with_exog).
The whole panel is validated up front (validation.validate_panel) so a shape
problem fails fast with a clear message — the same guard a real run uses. Then a single
series (ts_id, or the first one) is handed to worker.run_cell, exactly as an
engine would. run_cell never raises: a model failure comes back as an error cell.
Source code in src/scale_forecasting/playground.py
sample_data
¶
sample_data(
*,
n_series=3,
history=730,
freq="D",
with_exog=False,
with_hierarchy=False,
seed=_SAMPLE_SEED,
)
A small deterministic sample panel from the real generator.
Same code path as the shipped 100k dataset, so what you see locally is what runs at
scale. Columns: ts_id, archetype, ds, y (+ region, category when with_hierarchy
or with_exog, and promo_flag, price_index, temperature when with_exog).
Defaults to 3 series × 2 years daily — enough to show trend + seasonality + intervals.
Source code in src/scale_forecasting/playground.py
summarize
¶
A compact human-readable summary of a run — for the CLI and notebook printout.