Skip to content
Log inGet startedHugging FaceGitHub

Going further

Backtesting

Before you rely on a forecast, see how it would have done. evaluate cuts each series at a few points in its own past, forecasts from each cut, and scores the forecasts against what really happened, next to simple baselines.

res = model.evaluate(df, h=7, windows=3)
res.summary

The summary has one row per model (ChakraTS-OS-10M and each baseline) and one column per metric: mase, sql, wql, mae, rmse and coverage@0.8, then skill_<metric> for each. A skill says how much better than the seasonal baseline a model is: 0.25 means 25% lower error, and anything above 0 beats it.

A backtest of four past days and its calibration plotA backtest of four past days and its calibration plot
Four past days of Gulf Coast demand, each forecast from the history before it. The third was a hot day the history gave no sign of, and the forecast misses it; across all four regions, the quantiles stay close to calibrated.
  • windows: how many cuts per series (default 3), step apart (default h), at the end of each series.
  • baselines: seasonal_naive (repeats the last season: a week for daily data, a day for hourly) and naive (the last value). The first one is the reference for the skill columns.
  • metrics: mase, sql, wql, mae, rmse and coverage@0.8 (the share of actual values inside the 10% to 90% range). All are computed by default.
  • season: the seasonal period in steps, if you want to fix it instead of inferring it from the frequency.
  • past, known, preset, cross_series and the column names work as in forecast. Known covariates are read from the data over the history; nothing after a cut reaches that window’s forecast.
res.summary # per model: mean metrics and skill vs the baseline
res.scores # per series and window
res.forecasts # each window's quantiles next to the actual values
res.calibration # share of actual values below each quantile and inside each interval
res.plot() # each forecast against what happened (pip install "yhatmodels[plot]")
res.plot_calibration() # share below each quantile against its level

Score the forecasts you use today on the same windows:

res = model.evaluate(df, h=7, compare={"current": mine})

mine is a DataFrame with the id and time columns and either quantile columns (median, q10, …) or a point column named forecast.