← All projects
Data & analytics · Python
~

forecast

Time series forecasting with no dependencies — baselines first, exponential smoothing on top, and a MASE that tells you when you have not beaten “last January”.

01 Forecast monthly sales

6 years of monthly revenue (72 points, season length 12) embedded from data/monthly-sales.csv. Hold out the last points as a test window, pick a model, and see the forecast with 80% / 95% residual bands.

history (train) hold-out actual forecast shaded = 80% / 95% residual bands

02 All models on this split

Same train window, same horizon. MASE is scaled by seasonal naive on the training data — below 1 is a real improvement; 1.0 means you did no better than the baseline.

modelMASEMAERMSEsMAPE
Run a forecast to fill this table.

04 Synthetic series generator

Build your own series — trend, seasonal amplitude, noise and seed are yours to set — then forecast it live with any model above. Switch back to the embedded monthly-sales series whenever you like.

05 Model comparison overlay

Naive, SES, Holt and Holt-Winters forecast the same hold-out window on the same chart — every line comes from the real recursive updates in models above, fitted on the current train split.

modelMAERMSEMAPEMASE

06 Backtest walkthrough — rolling origin

One split can flatter a model. Step through expanding-window folds: fit on everything before the origin, forecast the next block, score it, then roll the origin forward. The bars below each fold are that fold's MASE for the selected model.

fold 1 / 3
train window test block (actual) forecast on this fold
foldtrain sizetest sizeMASEMAERMSEMAPE

07 Residual diagnostics

Residuals are hold-out actual minus forecast for the selected model. Left: autocorrelation-style bars for lags 1–12 — large bars mean the model left structure in the errors. Right: a quick normality hint from skewness and excess kurtosis.

residual ACF, lags 1–12 (|r| > 2/√n flagged)

03 Four things this gets right

  • MASE is scaled by the training window, not the test window — otherwise a hard test period makes every model look good.
  • Evaluation can be rolling origin rather than one arbitrary split (the package implements full backtesting).
  • Parameters are tuned at the horizon you forecast, not one step ahead.
  • Holt-Winters renormalises seasonal factors each season so they do not compete with the level — the slider above does the same.
50 tests · Python 3.10–3.12 · no runtime dependencies · Built by Umer Hashmi