Evaluating specialized models: units, baselines and readiness
Every model in this track has a natural unit that must not straddle training and test, a simple baseline it has to beat, and an honest label for what runs in CodeSplash. Put the three together before you trust a result.
What runs in CodeSplash
- SPE004TabPFN family Runs in CodeSplash (Experimental)
- SPE005Deep Sets Runs in CodeSplash (Experimental)
- SPE011SchNet Needs a data type CodeSplash doesn't load yet
- SPE014DeepONet Needs a data type CodeSplash doesn't load yet
- SPE016DeepAR Runs in CodeSplash (Experimental)
- SPE019PatchTST Runs in CodeSplash (Experimental)
- SEQ010Diffusion Policy Explained here
- SEQ013DiffDock Explained here
- SEQ014Chronos: tokenized probabilistic time-series forecasting Runs in CodeSplash
- SEQ015TimesFM: decoder-only time-series foundation model Explained here
- Chronos zero-shot forecast Checked in one engine
You will be able to
- Name the evaluation unit for tables, sets, molecules, operators and forecasts
- Pick the simple baseline each specialized model must beat
- Tell a component demo from a trained model, and an architecture proof from a test
- Read the readiness of every model in this track
Read first
Decide the unit first
ReadBefore any preprocessing, ask what must never appear on both sides of the split. That is the evaluation unitEvaluation unitWhat varies independently and must not sit in both training and test data: a patient, molecule, speaker, site or forecast origin., and in this track it is rarely a row:
| Data | Evaluation unit | Leak if you ignore it |
|---|---|---|
| Tables with repeated entities | entity (patient, store) | other rows of the same entity in training or in context |
| Sets and point clouds | whole set or object | elements of one set on both sides |
| Molecules and simulations | molecule, structure or trajectory | neighboring frames, near-identical molecules, related proteins |
| Operators | input function | the same forcing at a new query point |
| Forecasts | forecast origin, in time order | future values, overlapping windows, scaling fitted on the test period |
Then fit scaling, encodings and target construction inside the training part only.
Folds that keep units together
ExploreRandom row folds put pieces of one unit on both sides. Grouped foldsGrouped foldsFolds that keep all of an entity's rows on one side, so validation never sees a customer it trained on. keep each unit whole; for series, a backtestBacktestEvaluates a forecaster by repeatedly training on the past and predicting the next stretch. moves the origin forward in time. Compare the scores the two give when units repeat:
DExplorable · Cross-validation folds
Which rows should be held out so the score predicts real performance?
Each scheme has a tempting shortcut: training error, plain random folds, or the best score from a search. Will the shortcut here look better than the true error on new data?
Scheme
Commit your prediction above to see the result
Make your prediction to see the result.
The same goes for tuning: choose settings on validation units, then score the final choice once on held-out units.
Beat the simple thing
ReadEach specialized model has a simple rival it must beat, with the same splits and a matched tuning budget:
- Table networks (TabNet, FT-Transformer, TabPFN): a linear model and tuned boosted trees.
- Set models: a model on hand-made set summaries (means, counts, maxima).
- Deep and pretrained forecasters: the seasonal naive forecast, then ETS or ARIMA.
- Potentials, PINNs and operators: a numerical solver or a simpler physical model.
- Imputers: straight-line filling, then multiple imputation.
Report the spread over folds or origins, not one number. A gap inside that spread is a tie.
One model, two series
PredictPredict first
Chronos-Bolt Tiny forecasts airline passengers (monthly, strong trend and season) and Nile flows (annual, no season), zero-shot. How does it do against each series' naive forecast?
Reveal
It wins on one and ties on the other. On passengers its relative MAE is 0.59; on the Nile it is 1.02. A pretrained model's value depends on the series. Backtest it on yours.
Chronos-Bolt Tiny (zero-shot): 12-step forecasts of passengers (monthly data, 144 observations). Backtest MAE 28.1 over 2 origins.
- MAE
- 28.058
- RMSE
- 37.429
- MAPE
- 0.0582
Plots
View data
| hi_80 | hi_95 | kind | lo_80 | lo_95 | month | passengers |
|---|---|---|---|---|---|---|
| — | — | actual | — | — | −662,688,000,000 | 112 |
| — | — | actual | — | — | −660,009,600,000 | 118 |
| — | — | actual | — | — | −657,590,400,000 | 132 |
| — | — | actual | — | — | −654,912,000,000 | 129 |
| — | — | actual | — | — | −652,320,000,000 | 121 |
| — | — | actual | — | — | −649,641,600,000 | 135 |
| — | — | actual | — | — | −647,049,600,000 | 148 |
| — | — | actual | — | — | −644,371,200,000 | 148 |
| — | — | actual | — | — | −641,692,800,000 | 136 |
| — | — | actual | — | — | −639,100,800,000 | 119 |
| — | — | actual | — | — | −636,422,400,000 | 104 |
| — | — | actual | — | — | −633,830,400,000 | 118 |
| — | — | actual | — | — | −631,152,000,000 | 115 |
| — | — | actual | — | — | −628,473,600,000 | 126 |
| — | — | actual | — | — | −626,054,400,000 | 141 |
| — | — | actual | — | — | −623,376,000,000 | 135 |
| — | — | actual | — | — | −620,784,000,000 | 125 |
| — | — | actual | — | — | −618,105,600,000 | 149 |
| — | — | actual | — | — | −615,513,600,000 | 170 |
| — | — | actual | — | — | −612,835,200,000 | 170 |
| — | — | actual | — | — | −610,156,800,000 | 158 |
| — | — | actual | — | — | −607,564,800,000 | 133 |
| — | — | actual | — | — | −604,886,400,000 | 114 |
| — | — | actual | — | — | −602,294,400,000 | 140 |
| — | — | actual | — | — | −599,616,000,000 | 145 |
| — | — | actual | — | — | −596,937,600,000 | 150 |
| — | — | actual | — | — | −594,518,400,000 | 178 |
| — | — | actual | — | — | −591,840,000,000 | 163 |
| — | — | actual | — | — | −589,248,000,000 | 172 |
| — | — | actual | — | — | −586,569,600,000 | 178 |
| — | — | actual | — | — | −583,977,600,000 | 199 |
| — | — | actual | — | — | −581,299,200,000 | 199 |
| — | — | actual | — | — | −578,620,800,000 | 184 |
| — | — | actual | — | — | −576,028,800,000 | 162 |
| — | — | actual | — | — | −573,350,400,000 | 146 |
| — | — | actual | — | — | −570,758,400,000 | 166 |
| — | — | actual | — | — | −568,080,000,000 | 171 |
| — | — | actual | — | — | −565,401,600,000 | 180 |
| — | — | actual | — | — | −562,896,000,000 | 193 |
| — | — | actual | — | — | −560,217,600,000 | 181 |
| — | — | actual | — | — | −557,625,600,000 | 183 |
| — | — | actual | — | — | −554,947,200,000 | 218 |
| — | — | actual | — | — | −552,355,200,000 | 230 |
| — | — | actual | — | — | −549,676,800,000 | 242 |
| — | — | actual | — | — | −546,998,400,000 | 209 |
| — | — | actual | — | — | −544,406,400,000 | 191 |
| — | — | actual | — | — | −541,728,000,000 | 172 |
| — | — | actual | — | — | −539,136,000,000 | 194 |
| — | — | actual | — | — | −536,457,600,000 | 196 |
| — | — | actual | — | — | −533,779,200,000 | 196 |
| — | — | actual | — | — | −531,360,000,000 | 236 |
| — | — | actual | — | — | −528,681,600,000 | 235 |
| — | — | actual | — | — | −526,089,600,000 | 229 |
| — | — | actual | — | — | −523,411,200,000 | 243 |
| — | — | actual | — | — | −520,819,200,000 | 264 |
| — | — | actual | — | — | −518,140,800,000 | 272 |
| — | — | actual | — | — | −515,462,400,000 | 237 |
| — | — | actual | — | — | −512,870,400,000 | 211 |
| — | — | actual | — | — | −510,192,000,000 | 180 |
| — | — | actual | — | — | −507,600,000,000 | 201 |
First 60 of 156 rows.
View data
| error | horizon | origin |
|---|---|---|
| 1.382 | 1 | 1958-12-01 |
| −28.974 | 2 | 1958-12-01 |
| 23.417 | 3 | 1958-12-01 |
| 5.815 | 4 | 1958-12-01 |
| 15.075 | 5 | 1958-12-01 |
| 31.007 | 6 | 1958-12-01 |
| 76.172 | 7 | 1958-12-01 |
| 85.563 | 8 | 1958-12-01 |
| 18.147 | 9 | 1958-12-01 |
| 26.884 | 10 | 1958-12-01 |
| 0.1960 | 11 | 1958-12-01 |
| 35.543 | 12 | 1958-12-01 |
| −4.135 | 1 | 1959-12-01 |
| −39.437 | 2 | 1959-12-01 |
| −20.612 | 3 | 1959-12-01 |
| 14.798 | 4 | 1959-12-01 |
| 9.992 | 5 | 1959-12-01 |
| 31.673 | 6 | 1959-12-01 |
| 81.930 | 7 | 1959-12-01 |
| 64.000 | 8 | 1959-12-01 |
| 2.102 | 9 | 1959-12-01 |
| 24.712 | 10 | 1959-12-01 |
| −28.604 | 11 | 1959-12-01 |
| 3.217 | 12 | 1959-12-01 |
View data
| quantile | month | passengers |
|---|---|---|
| — | −378,691,200,000 | 340 |
| — | −376,012,800,000 | 318 |
| — | −373,593,600,000 | 362 |
| — | −370,915,200,000 | 348 |
| — | −368,323,200,000 | 363 |
| — | −365,644,800,000 | 435 |
| — | −363,052,800,000 | 491 |
| — | −360,374,400,000 | 505 |
| — | −357,696,000,000 | 404 |
| — | −355,104,000,000 | 359 |
| — | −352,425,600,000 | 310 |
| — | −349,833,600,000 | 337 |
| — | −347,155,200,000 | 360 |
| — | −344,476,800,000 | 342 |
| — | −342,057,600,000 | 406 |
| — | −339,379,200,000 | 396 |
| — | −336,787,200,000 | 420 |
| — | −334,108,800,000 | 472 |
| — | −331,516,800,000 | 548 |
| — | −328,838,400,000 | 559 |
| — | −326,160,000,000 | 463 |
| — | −323,568,000,000 | 407 |
| — | −320,889,600,000 | 362 |
| — | −318,297,600,000 | 405 |
| — | −315,619,200,000 | 417 |
| — | −312,940,800,000 | 391 |
| — | −310,435,200,000 | 419 |
| — | −307,756,800,000 | 461 |
| — | −305,164,800,000 | 472 |
| — | −302,486,400,000 | 535 |
| — | −299,894,400,000 | 622 |
| — | −297,216,000,000 | 606 |
| — | −294,537,600,000 | 508 |
| — | −291,945,600,000 | 461 |
| — | −289,267,200,000 | 390 |
| — | −286,675,200,000 | 432 |
| 0.1000 | −283,996,800,000 | 426.96 |
| 0.1000 | −281,318,400,000 | 437.42 |
| 0.1000 | −278,899,200,000 | 447.06 |
| 0.1000 | −276,220,800,000 | 454.99 |
| 0.1000 | −273,628,800,000 | 474.54 |
| 0.1000 | −270,950,400,000 | 515.18 |
| 0.1000 | −268,358,400,000 | 551.34 |
| 0.1000 | −265,680,000,000 | 553.89 |
| 0.1000 | −263,001,600,000 | 509.52 |
| 0.1000 | −260,409,600,000 | 432.81 |
| 0.1000 | −257,731,200,000 | 412.51 |
| 0.1000 | −255,139,200,000 | 422.11 |
| 0.2000 | −283,996,800,000 | 436.34 |
| 0.2000 | −281,318,400,000 | 447.77 |
| 0.2000 | −278,899,200,000 | 458.70 |
| 0.2000 | −276,220,800,000 | 468.34 |
| 0.2000 | −273,628,800,000 | 487.90 |
| 0.2000 | −270,950,400,000 | 530.07 |
| 0.2000 | −268,358,400,000 | 569.17 |
| 0.2000 | −265,680,000,000 | 573.56 |
| 0.2000 | −263,001,600,000 | 528.67 |
| 0.2000 | −260,409,600,000 | 447.17 |
| 0.2000 | −257,731,200,000 | 428.01 |
| 0.2000 | −255,139,200,000 | 439.52 |
First 60 of 144 rows.
Assumptions
- Horizon within the model's training — Horizon 12; Chronos-Bolt predicts up to 64 steps at once.
- Enough history for the model — The model read 144 values.
- Beats the seasonal naive forecast — Backtest MAE is 0.59 times the seasonal naive forecast's from the same origins.
Backtest accuracy (2 origins, horizon 12)
| Metric | Value |
|---|---|
| MAE | 28.058 |
| RMSE | 37.429 |
| MAPE | 0.0582 |
| sMAPE | 0.0599 |
| MASE | 0.9527 |
| WAPE | 0.0620 |
| Coverage of the 80% interval | 0.7500 |
| Coverage of the 95% interval | 0.8750 |
The model's quantiles (the 50% quantile is the forecast)
| month | 10% | 20% | 30% | 40% | 50% | 60% | 70% | 80% | 90% |
|---|---|---|---|---|---|---|---|---|---|
| 1961-01-01 | 426.96 | 436.34 | 443.24 | 449.75 | 456.54 | 463.19 | 470.40 | 478.39 | 490.93 |
| 1961-02-01 | 437.42 | 447.77 | 455.59 | 462.43 | 469.48 | 476.56 | 483.67 | 492.25 | 504.40 |
| 1961-03-01 | 447.06 | 458.70 | 467.69 | 474.88 | 483.33 | 491.30 | 499.66 | 508.56 | 521.03 |
| 1961-04-01 | 454.99 | 468.34 | 477.58 | 485.73 | 493.49 | 502.31 | 510.19 | 519.77 | 531.07 |
| 1961-05-01 | 474.54 | 487.90 | 496.81 | 504.17 | 511.93 | 519.80 | 528.40 | 537.22 | 549.30 |
| 1961-06-01 | 515.18 | 530.07 | 540.73 | 549.17 | 558.58 | 568.29 | 578.01 | 589.19 | 604.29 |
| 1961-07-01 | 551.34 | 569.17 | 581.38 | 591.50 | 602.37 | 613.18 | 624.62 | 636.84 | 654.22 |
| 1961-08-01 | 553.89 | 573.56 | 586.38 | 597.55 | 609.33 | 620.58 | 632.28 | 644.47 | 662.18 |
| 1961-09-01 | 509.52 | 528.67 | 541.69 | 552.80 | 563.82 | 575.09 | 586.64 | 599.81 | 616.24 |
| 1961-10-01 | 432.81 | 447.17 | 458.14 | 467.39 | 477.71 | 488.21 | 498.13 | 509.09 | 526.68 |
| 1961-11-01 | 412.51 | 428.01 | 439.79 | 449.19 | 458.74 | 468.49 | 477.87 | 488.31 | 502.88 |
| 1961-12-01 | 422.11 | 439.52 | 451.29 | 461.58 | 471.21 | 480.47 | 490.32 | 501.73 | 519.74 |
Pretrained weights
| Item | Value |
|---|---|
| Model | Chronos-Bolt Tiny (9M parameters) |
| Source | huggingface.co/amazon/chronos-bolt-tiny |
| Revision | a0e552de83495b5c28c14c71c374f3e33280b340 |
| License | Apache-2.0 |
| Download size | 34.6 MB |
Forecast
| month | Forecast | 80% low | 80% high | 95% low | 95% high |
|---|---|---|---|---|---|
| 1961-01-01 | 456.54 | 426.96 | 490.93 | 411.30 | 509.14 |
| 1961-02-01 | 469.48 | 437.42 | 504.40 | 420.44 | 522.88 |
| 1961-03-01 | 483.33 | 447.06 | 521.03 | 427.87 | 540.99 |
| 1961-04-01 | 493.49 | 454.99 | 531.07 | 434.61 | 550.97 |
| 1961-05-01 | 511.93 | 474.54 | 549.30 | 454.75 | 569.08 |
| 1961-06-01 | 558.58 | 515.18 | 604.29 | 492.21 | 628.48 |
| 1961-07-01 | 602.37 | 551.34 | 654.22 | 524.33 | 681.67 |
| 1961-08-01 | 609.33 | 553.89 | 662.18 | 524.54 | 690.16 |
| 1961-09-01 | 563.82 | 509.52 | 616.24 | 480.78 | 643.99 |
| 1961-10-01 | 477.71 | 432.81 | 526.68 | 409.03 | 552.59 |
| 1961-11-01 | 458.74 | 412.51 | 502.88 | 388.04 | 526.25 |
| 1961-12-01 | 471.21 | 422.11 | 519.74 | 396.11 | 545.43 |
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Chronos zero-shot forecast
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method forecast.chronos 1.1.1 · spec 202261816b326ed3
# Dataset: ml_airpassengers (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import math
import os
import numpy as np
import pandas as pd
import codesplash as cs
from codesplash import ml as csml
from codesplash.ml import forecast as fc
from codesplash.deep import chronos as cbolt # pretrained weights, looked up locally only (never downloaded here)
# %% Data
TIME = "month"
VALUE = "passengers"
SERIES = None
H = 12
LEVELS = [float(v) for v in [80, 95]]
SEASON = None # None = from the time steps (12 monthly, 4 quarterly, 7 daily …)
WINDOWS = 2
STEP = None # None = the horizon
OFFSETS = None # the host's BacktestPlan: distance of each origin from the end of the series; None = windows and step
TRAIN_WINDOW = None # None = train on all values before each origin
TRAIN_START = None # rows before this time are left out (for example, before a structural break)
SEED = 42
XREG = []
PARAMS = {
"model": "bolt_tiny",
"context": None,
}
df = pd.read_parquet("tests/parity/fixtures/ml_airpassengers.parquet", columns=list(dict.fromkeys([c for c in (TIME, VALUE, SERIES) if c] + list(XREG))))
cs.check_finite_columns(df, [TIME, VALUE] + list(XREG)) # infinite values stop with CS_E_NOT_FINITE, naming the column
if len(df) == 0:
cs.cs_error("CS_E_NO_ROWS")
warnings = []
times_all, TEMPORAL = fc.to_days(df[TIME])
values_all = pd.to_numeric(df[VALUE], errors="coerce").to_numpy(dtype=np.float64)
x_all = np.column_stack([pd.to_numeric(df[c], errors="coerce").to_numpy(dtype=np.float64) for c in XREG]) if XREG else None
if TRAIN_START is not None:
cut = fc.parse_time(TRAIN_START, TEMPORAL)
early = np.nan_to_num(times_all, nan=np.inf) < cut
if early.any():
warnings.append(f"{int(early.sum())} rows before {TRAIN_START} were left out of training.")
times_all = np.where(early, np.nan, times_all)
keys_all = df[SERIES].astype("object").to_numpy() if SERIES else np.array([None] * len(df), dtype=object)
dropped = int(np.isnan(times_all).sum()) - (int(early.sum()) if TRAIN_START is not None else 0)
if dropped:
warnings.append(f"{dropped} rows without a time were left out.")
series_keys = sorted({str(k) for k in keys_all if not pd.isna(k)}) if SERIES else [None] # None, NaN, pd.NA: no name
if SERIES and any(pd.isna(k) for k in keys_all):
warnings.append("Rows without a series name were left out.")
# Degenerate inputs stop with catalog codes, in the same order as the R driver.
if bool(np.isnan(values_all).all()):
cs.cs_error("CS_E_ALL_MISSING", column=VALUE)
if not bool((~np.isnan(times_all) & ~np.isnan(values_all)).any()):
cs.cs_error("CS_E_NO_ROWS")
out = csml.out_dir("target/academy-parity/run-8142/forecast.chronos/tiny_monthly/out-python")
extra_tables = [] # model blocks may add result tables (e.g. automatic selection)
extra_assumptions = [] # … and assumption rows
current_series = None
X_TRAIN = None # regressors while fit_forecast runs: rows × regressors, aligned with its y
X_FUTURE = None # … and h × regressors for the steps it forecasts
# Model blocks may set DIAG[current_series] = {"resid": [...], "fitdf": k, "lags": L} from each fit (the final fit's
# entry is kept): the residuals their own check tests when that is not actual − fitted (GARCH: standardized; ARIMAX:
# the ARMA errors), the ARMA terms they were filtered with, and the Ljung–Box lags when the method's rule differs from
# min(2m, n/5). They go to forecast.parquet so the host's Residuals tab tests the same thing.
DIAG = {}
# %% Model
# Chronos-Bolt (Ansari et al. 2024) is pretrained: it reads the recent history and predicts quantiles of the next
# steps without training on this series. Python only — the weights run through the chronos-forecasting package.
# The weights must already be on this computer (the app downloads them only after you confirm the size).
FINAL = {}
WEIGHTS = cbolt.locate(PARAMS["model"]) # stops with CS_WEIGHTS_MISSING and the download size when absent
def min_train(m):
return 8
def prepare_series(y, t, m, freq):
return None
def fit_forecast(y, t, h, m, levels, spec):
res = cbolt.fit_forecast(y, h, m, levels, model=PARAMS["model"], context=PARAMS["context"])
FINAL[current_series] = (res, [float(v) for v in t])
return res
# %% Backtests and forecasts
def lv(level):
return str(int(level)) if float(level).is_integer() else str(level).replace(".", "_")
bt_rows = []
fc_rows = []
facts = {}
labels = {}
freq_label = ""
freq_alias = ""
seasons = []
n_obs = 0
n_origins = 0
filled = 0
residuals_first = None
for key in series_keys:
current_series = key # model blocks may read it (e.g. table titles)
sel = ~np.isnan(times_all) & ((keys_all.astype(str) == key) if SERIES else True)
t_raw, y_raw = times_all[sel], values_all[sel]
if int(np.sum(~np.isnan(y_raw))) < 3: # too few values to read the time step from
cs.cs_error("CS_E_TOO_FEW_ROWS", what=("Forecasting" if key is None else f"Series {key}"), min=min_train(1) + 1, n=int(np.sum(~np.isnan(y_raw))))
x_later = None
if XREG: # rows after the last observed value carry known future regressors
x_raw = x_all[sel]
last_y = np.nanmax(np.where(np.isnan(y_raw), np.nan, t_raw))
later = t_raw > last_y
order_later = np.argsort(t_raw[later], kind="stable")
x_later = x_raw[later][order_later]
t_raw, y_raw, x_raw = t_raw[~later], y_raw[~later], x_raw[~later]
freq = fc.detect_frequency(np.sort(t_raw), TEMPORAL)
t, y, nfill = fc.regularize(t_raw, y_raw, freq)
x_grid = np.column_stack([fc.regularize(t_raw, x_raw[:, j], freq)[1] for j in range(x_raw.shape[1])]) if XREG else None
filled += nfill
freq_label = freq["label"]
freq_alias = fc.ALIASES.get(freq["unit"], "")
m = int(SEASON) if SEASON else int(freq["season"])
seasons.append(m)
y = [float(v) for v in y]
n = len(y)
n_obs += n
if n < min_train(m) + 1:
cs.cs_error("CS_E_TOO_FEW_ROWS", what=("Forecasting" if key is None else f"Series {key}"), min=min_train(m) + 1, n=n)
spec = prepare_series(y, t, m, freq)
step = int(STEP) if STEP else H
if OFFSETS is not None:
origins = fc.plan_origins(n, H, [int(v) for v in OFFSETS], min_train(m))
if len(origins) < len(OFFSETS):
warnings.append(f"{len(OFFSETS) - len(origins)} of {len(OFFSETS)} backtest origins were skipped for {key or VALUE}: too few values before them.")
else:
origins = fc.backtest_origins(n, H, WINDOWS, step, min_train(m))
for o in origins:
start = max(0, o - int(TRAIN_WINDOW)) if TRAIN_WINDOW else 0
if XREG:
X_TRAIN, X_FUTURE = x_grid[start:o], x_grid[o:o + H]
try:
res = fit_forecast(y[start:o], t[start:o], H, m, LEVELS, spec)
except Exception as e: # a failed origin is skipped, not fatal
warnings.append(f"Backtest from {fc.format_time(t[o - 1], TEMPORAL)} failed: {e}")
continue
n_origins += 1
scale = fc.mase_scale(y[:o], m)
scale2 = fc.rmsse_scale(y[:o], m)
lag = m if (m > 1 and o > m) else 1 # the seasonal naive forecast from this origin (MASE's lag rule)
for k in range(H):
row = {
"series": key,
"origin": fc.format_time(t[o - 1], TEMPORAL),
"time": fc.format_time(t[o + k], TEMPORAL),
"h": k + 1,
"actual": y[o + k],
"mean": float(res["mean"][k]),
"scale": scale,
"scale2": scale2,
"last": y[o - 1],
"snaive": y[o - lag + k % lag],
}
for level in LEVELS:
row[f"lo_{lv(level)}"] = float(res["lower"][level][k])
row[f"hi_{lv(level)}"] = float(res["upper"][level][k])
bt_rows.append(row)
if XREG:
X_TRAIN = x_grid
X_FUTURE = fc.future_regressors(x_grid, x_later, H)
if len(x_later) < H:
warnings.append(f"Future values of {', '.join(XREG)} are known for {len(x_later)} of {H} steps; the last known values are held for the rest.")
final = fit_forecast(y, t, H, m, LEVELS, spec)
labels[key] = final["label"]
for name, value in final["facts"].items():
facts[name if not SERIES else f"{name}[{key}]"] = value
fitted = final.get("fitted")
diag = DIAG.get(key) or {}
resid = diag.get("resid")
if residuals_first is None and resid is not None:
residuals_first = [float(v) for v in resid]
elif residuals_first is None and fitted is not None:
residuals_first = [y[i] - fitted[i] for i in range(n) if fitted[i] is not None and not math.isnan(fitted[i])]
for i in range(n):
row = {"series": key, "time": fc.format_time(t[i], TEMPORAL), "t": float(t[i]), "kind": "actual", "mean": y[i]}
if resid is not None and i >= n - len(resid): # the last len(resid) times (differencing drops early ones)
row["resid"] = float(resid[i - (n - len(resid))])
if "fitdf" in diag:
row["lb_fitdf"] = float(diag["fitdf"])
if "lags" in diag:
row["lb_lags"] = float(diag["lags"])
fc_rows.append(row)
if fitted is not None and not math.isnan(fitted[i]):
fc_rows.append({"series": key, "time": fc.format_time(t[i], TEMPORAL), "t": float(t[i]), "kind": "fitted", "mean": float(fitted[i])})
future = fc.future_times(t[-1], freq, H)
for k in range(H):
row = {"series": key, "time": fc.format_time(future[k], TEMPORAL), "t": float(future[k]), "kind": "forecast", "mean": float(final["mean"][k])}
for level in LEVELS:
row[f"lo_{lv(level)}"] = float(final["lower"][level][k])
row[f"hi_{lv(level)}"] = float(final["upper"][level][k])
fc_rows.append(row)
if filled:
warnings.append(f"{filled} missing time steps or values were filled by linear interpolation.")
# %% Accuracy
accuracy = fc.accuracy(bt_rows, LEVELS)
forecasts = [r for r in fc_rows if r["kind"] == "forecast"]
weights = [i + 1.0 for i in range(len(forecasts))]
top = lv(max(LEVELS)) if LEVELS else None
def wsum(xs):
return fc._sum([weights[i] * xs[i] for i in range(len(xs))]) / fc._sum(weights)
values = {
"n_series": len(series_keys),
"n_obs": n_obs,
"horizon": H,
"season": seasons[0],
"n_origins": n_origins,
"filled": filled,
"fc_check": wsum([r["mean"] for r in forecasts]),
"model_label": labels[series_keys[0]] if len(series_keys) == 1 else f"{len(series_keys)} series, one model each",
"freq_label": freq_label,
"frequency": freq_alias,
}
if top:
values["fc_lo_check"] = wsum([r[f"lo_{top}"] for r in forecasts])
values["fc_hi_check"] = wsum([r[f"hi_{top}"] for r in forecasts])
for k, v in accuracy.items():
values[f"bt[{k}]"] = v
values.update(facts)
pd.DataFrame(fc_rows).to_parquet(os.path.join(out, "forecast.parquet"), index=False)
artifacts = [{"key": "forecast", "path": os.path.join(out, "forecast.parquet"), "format": "parquet"}]
if bt_rows:
pd.DataFrame(bt_rows).to_parquet(os.path.join(out, "backtest.parquet"), index=False)
artifacts.append({"key": "backtest", "path": os.path.join(out, "backtest.parquet"), "format": "parquet"})
# %% Charts
charts = []
shown = series_keys[:8]
fan = [r for r in fc_rows if r["series"] in shown and r["kind"] != "fitted"]
kind = "temporal" if TEMPORAL else "numeric"
roles = {
"time": cs.col(TIME, [r["time"] for r in fan], kind=kind),
"value": cs.col(VALUE, [r["mean"] for r in fan], kind="numeric"),
"kind": cs.col("kind", [r["kind"] for r in fan], kind="categorical", levels=["actual", "forecast"]),
}
for level in (80.0, 95.0):
if level in LEVELS:
roles[f"lo_{lv(level)}"] = cs.col(f"lo_{lv(level)}", [r.get(f"lo_{lv(level)}") for r in fan], kind="numeric")
roles[f"hi_{lv(level)}"] = cs.col(f"hi_{lv(level)}", [r.get(f"hi_{lv(level)}") for r in fan], kind="numeric")
if SERIES:
roles["series"] = cs.col(SERIES, [r["series"] for r in fan], kind="categorical", levels=shown)
charts.append(cs.chart("forecast", "forecast-fan", f"Forecast of {VALUE}", roles))
if bt_rows:
charts.append(
cs.chart(
"backtest",
"backtest-errors",
"Backtest errors by horizon",
{
"h": cs.col("horizon", [r["h"] for r in bt_rows], kind="numeric"),
"error": cs.col("error", [r["actual"] - r["mean"] for r in bt_rows], kind="numeric"),
"origin": cs.col("origin", [r["origin"] for r in bt_rows], kind="categorical"),
},
)
)
if residuals_first and len(residuals_first) > 4:
lags = min(max(2 * seasons[0], 10), len(residuals_first) - 1, 48)
r_acf = fc.acf(residuals_first, lags)
bound = 1.959963984540054 / math.sqrt(len(residuals_first))
charts.append(
cs.chart(
"acf",
"acf-plot",
"Residual autocorrelation",
{
"lag": cs.col("lag", list(range(1, lags + 1)), kind="numeric"),
"acf": cs.col("ACF", r_acf, kind="numeric"),
"bound": cs.col("bound", [bound] * lags, kind="numeric"),
},
)
)
# %% Quantiles and checks
res0, t0 = FINAL[series_keys[0]]
spec0 = cbolt.MODELS[PARAMS["model"]]
freq0 = fc.detect_frequency(np.array(t0), TEMPORAL)
times0 = [fc.format_time(v, TEMPORAL) for v in fc.future_times(t0[-1], freq0, H)]
lq0, q0 = res0["quantile_levels"], res0["quantiles"]
wq = [(j + 1.0) * (k + 1.0) for j in range(len(lq0)) for k in range(H)]
values["q_check"] = fc._sum([wq[j * H + k] * float(q0[j, k]) for j in range(len(lq0)) for k in range(H)]) / fc._sum(wq)
values["weights_label"] = spec0["label"]
suffix0 = f" — {series_keys[0]}" if SERIES else ""
hist0 = min(len(t0), max(3 * H, 24))
y0 = [r["mean"] for r in fc_rows if r["series"] == series_keys[0] and r["kind"] == "actual"][-hist0:]
th0 = [r["time"] for r in fc_rows if r["series"] == series_keys[0] and r["kind"] == "actual"][-hist0:]
charts.append(
cs.chart(
"quantiles",
"quantile-fan",
f"Chronos quantiles for {VALUE}" + suffix0,
{
"time": cs.col(TIME, th0 + [times0[k] for j in range(len(lq0)) for k in range(H)], kind="temporal" if TEMPORAL else "numeric"),
"value": cs.col(VALUE, y0 + [float(q0[j, k]) for j in range(len(lq0)) for k in range(H)], kind="numeric"),
"quantile": cs.col("quantile", [None] * len(y0) + [lq0[j] for j in range(len(lq0)) for k in range(H)], kind="numeric"),
},
)
)
extra_tables.append(
{
"key": "quantiles",
"title": "The model's quantiles (the 50% quantile is the forecast)" + suffix0,
"columns": [{"key": "time", "label": TIME}] + [{"key": f"q{int(round(p * 100))}", "label": f"{int(round(p * 100))}%", "type": "number"} for p in lq0],
"rows": [dict({"time": times0[k]}, **{f"q{int(round(p * 100))}": float(q0[j, k]) for j, p in enumerate(lq0)}) for k in range(H)],
}
)
extra_tables.append(
{
"key": "weights",
"title": "Pretrained weights",
"columns": [{"key": "item", "label": "Item"}, {"key": "value", "label": "Value"}],
"rows": [
{"item": "Model", "value": f"{spec0['label']} ({spec0['params']} parameters)"},
{"item": "Source", "value": f"huggingface.co/{spec0['repo']}"},
{"item": "Revision", "value": spec0["revision"]},
{"item": "License", "value": "Apache-2.0"},
{"item": "Download size", "value": cbolt.size_text(spec0["bytes"])},
],
}
)
extra_assumptions.append(
{
"key": "horizon_trained",
"label": "Horizon within the model's training",
"status": "pass" if H <= cbolt.TRAINED_HORIZON else "warn",
"statistic": float(H),
"detail": f"Horizon {H}; Chronos-Bolt predicts up to {cbolt.TRAINED_HORIZON} steps at once." + ("" if H <= cbolt.TRAINED_HORIZON else " Later steps feed the model's own forecasts back, so they can drift."),
}
)
ctx0 = int(res0["facts"]["context"])
extra_assumptions.append(
{
"key": "context_length",
"label": "Enough history for the model",
"status": "pass" if ctx0 >= 64 else "warn",
"statistic": float(ctx0),
"detail": f"The model read {ctx0} values." + ("" if ctx0 >= 64 else " Fewer than 64 (four patches of 16) leaves little pattern to recognize."),
}
)
rel0 = fc.naive_relative_mae(bt_rows) # not MASE < 1: MASE scales by the in-sample one-step naive error
if math.isfinite(rel0):
values["bt[rel_mae]"] = rel0
beats0 = rel0 < 1
extra_assumptions.append(
{
"key": "beats_naive",
"label": "Beats the seasonal naive forecast",
"status": "pass" if beats0 else "warn",
"statistic": rel0,
"detail": f"Backtest MAE is {rel0:.2f} times the seasonal naive forecast's from the same origins." + ("" if beats0 else " Repeating the last season forecast these origins at least as well."),
}
)
if H > cbolt.TRAINED_HORIZON:
warnings.append(f"Chronos-Bolt was trained for up to {cbolt.TRAINED_HORIZON} steps; steps beyond that are rolled forward from its own forecasts.")
# %% Result
show = [m for m in ("mae", "rmse", "mape", "smape", "mase", "wape") if m in accuracy]
tables = []
if accuracy:
tables.append(
{
"key": "accuracy",
"title": f"Backtest accuracy ({n_origins} origin{'s' if n_origins != 1 else ''}, horizon {H})",
"columns": [{"key": "metric", "label": "Metric"}, {"key": "value", "label": "Value", "type": "number"}],
"rows": [{"metric": k.upper() if k != "smape" else "sMAPE", "value": accuracy[k]} for k in show]
+ [{"metric": f"Coverage of the {lv(level)}% interval", "value": accuracy.get(f"coverage_{lv(level)}")} for level in LEVELS if f"coverage_{lv(level)}" in accuracy],
}
)
tables.extend(extra_tables)
tables.append(
{
"key": "forecast",
"title": "Forecast",
"columns": ([{"key": "series", "label": "Series"}] if SERIES else [])
+ [{"key": "time", "label": TIME}, {"key": "mean", "label": "Forecast", "type": "number"}]
+ [c for level in LEVELS for c in ({"key": f"lo_{lv(level)}", "label": f"{lv(level)}% low", "type": "number"}, {"key": f"hi_{lv(level)}", "label": f"{lv(level)}% high", "type": "number"})],
"rows": [{k: v for k, v in r.items() if k not in ("t", "kind") and (SERIES or k != "series")} for r in forecasts[:200]],
}
)
summary = f"{values['model_label']}: {H}-step forecasts of {VALUE} ({freq_label} data, {n_obs} observations)."
if "mae" in accuracy:
summary += f" Backtest MAE {accuracy['mae']:.3g} over {n_origins} origin{'s' if n_origins != 1 else ''}."
cs.publish(
{
"title": "Chronos zero-shot forecast",
"engine": cs.engine_info("chronos-forecasting", "torch", "numpy", "pandas"),
"n": n_obs,
"summary": summary,
"statistics": [{"key": k, "label": k.upper(), "value": accuracy[k]} for k in show[:3]],
"tables": tables,
"values": values,
"assumptions": extra_assumptions,
"warnings": warnings,
"notes": [],
"charts": charts,
"artifacts": artifacts,
}
)
A demo is not a model
ReadEvery reference program in this track is a component demo: a sparsemax mask, a set map, one EdgeConv step, a residual, a bin table. Each checks one idea exactly. None trains or reproduces the published model, so none tells you how well that model works on data.
Likewise, an architecture proof (invariance, equivariance, a conserved energy) holds for ideal layers in exact arithmetic. Preprocessing, cutoffs, solvers and rounding can break it, so test it numerically on real inputs. And a model's own loss (denoising, contrastive, pinball) is a training signal, not the claim you want to make.
What runs in CodeSplash
Read| Entries | Readiness | Where |
|---|---|---|
| SPE001 TabNet, SPE002 FT-Transformer, SPE005 Deep Sets, SPE006 Set Transformer | Runs in CodeSplash | Predict: learn.tabnet, learn.ft_transformer, learn.set_model |
| SPE004 TabPFN | Runs in CodeSplash, Python only | Predict: learn.tabpfn |
| SPE003 SAINT, SPE007 PointNet | Partly runs | options of learn.ft_transformer and learn.set_model |
| SPE016 DeepAR, SPE017 TFT, SPE018 N-BEATS, SPE019 PatchTST, SEQ016 N-HiTS, SEQ001 TimeGrad | Runs in CodeSplash | Forecast |
| SEQ014 Chronos | Runs in CodeSplash, Python only | Forecast: forecast.chronos, forecast.chronos2 |
| SPE020 TS2Vec, SEQ004 DenStream | Runs in CodeSplash | Discover: discover.ts_embed, discover.stream_clusters |
| SEQ002 CSDI, SEQ003 Neural CDE | Runs in CodeSplash | missing.csdi, learn.neural_cde |
| SPE008–012, SPE014, SPE015, SEQ005 | Needs a data type CodeSplash doesn't load yet | point clouds, geometric graphs, molecules, function data, timed interaction graphs |
| SPE013 PINN, SEQ010 Diffusion Policy, SEQ012 HNN, SEQ013 DiffDock, SEQ015 TimesFM | Explained here | Academy only |
Check: evaluating specialized models
CheckpointCheck yourself
A clinic table has several visits per patient. You evaluate TabPFN with random row folds and get excellent scores. What is wrong?
Show the answer
Answer: a
Context counts as training data for leakage. Fold by patient.
Check yourself
What baseline should a Deep Sets model beat before you prefer it?
Show the answer
Answer: a
If simple summaries do as well, the network's learned pooling adds little.
Check yourself
A docking or potential model is tested on a random split of a database with many near-identical molecules and related proteins. What is the risk?
Show the answer
Answer: b
Split by molecule family, scaffold or protein similarity so the test resembles real new cases.
Check yourself
For a neural operator, what must be held out?
Show the answer
Answer: b
New query points of a seen input don't test the operator's claim: generalizing across inputs.
Check yourself
How should a DeepAR forecaster be evaluated?
Show the answer
Answer: b
The unit is the forecast origin. Future data must never inform the model or its scaling.
Check yourself
PatchTST's training windows overlap heavily. Why can't you split windows randomly into train and test?
Show the answer
Answer: a
Split by time (and by series when there are many), never by individual window.
Check yourself
A pretrained forecaster beats the naive forecast on one series and ties on another. What follows?
Show the answer
Answer: b
Pretraining helps most on series like the pretraining data. Baselines settle each case.
Check yourself
What is the evaluation unit for a learned robot policy?
Show the answer
Answer: b
Policies are judged on task outcomes per episode. Held-out frames say little about closed-loop behavior.
Check yourself
A reference program computes a model's loss on a few fixed numbers and passes its assertions. What has it shown?
Show the answer
Answer: b
Component demos check an idea. Performance needs a trained model and an honest evaluation.
Recap
Recap- Decide the evaluation unit first: entity, set, molecule, input function or forecast origin.
- Beat the simple rival on the same splits, and report the spread.
- Component demos and architecture proofs check ideas, not performance.
- Read each entry's readiness: many run in CodeSplash, some need data types it doesn't load yet, a few are explained here only.
Concepts in this lesson