Skip to content
Skills Library
Data & analytics · Analysis

forecast-backtest

/forecast-backtest

Use when building, evaluating or comparing time-series forecasts (demand, sales, prices, traffic, energy and similar). Forces baselines first, a rolling-origin backtest, leakage checks and an honest report. Triggers include forecast, backtest, time series, predict the next N periods, compare forecasting models, tahmin, zaman serisi, tahmin modeli karşılaştır, geriye dönük test.

Licence
MIT
Last repository change
08.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
17
Scripts
7
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 08.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • 7 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: examples/ets_daily.py, examples/ets_monthly.py, examples/ets_weekly.py, examples/prophet_daily.py, examples/yearly_harmonic.py, scripts/backtest.py, scripts/test_backtest.py

What it does and when to use it

Use when building, evaluating or comparing time-series forecasts (demand, sales, prices, traffic, energy and similar). Forces baselines first, a rolling-origin backtest, leakage checks and an honest report. Triggers include forecast, backtest, time series, predict the next N periods, compare forecasting models, tahmin, zaman serisi, tahmin modeli karşılaştır, geriye dönük test.

Original author description

Use when building, evaluating or comparing time-series forecasts (demand, sales, prices, traffic, energy and similar). Forces baselines first, a rolling-origin backtest, leakage checks and an honest report. Triggers include forecast, backtest, time series, predict the next N periods, compare forecasting models, tahmin, zaman serisi, tahmin modeli karşılaştır, geriye dönük test.

How it works

  1. Workflow
  2. Usage
  3. Limits
Original SKILL.md headings · 91 lines, 909 words
SKILL.md preview
---
name: forecast-backtest
description: Use when building, evaluating or comparing time-series forecasts (demand, sales, prices, traffic, energy and similar). Forces baselines first, a rolling-origin backtest, leakage checks and an honest report. Triggers include forecast, backtest, time series, predict the next N periods, compare forecasting models, tahmin, zaman serisi, tahmin modeli karşılaştır, geriye dönük test.
---

# Forecast, then prove it beats a baseline

A model is not "good" until it beats the best baseline on a rolling-origin backtest.
Report that comparison even when it is bad news. Do not jump to a fancy model first.

## Workflow

1. **Frame it.** Pin down, and ask if unclear: horizon, frequency, season length
   (12 monthly, 7 daily, 24 hourly), the target, and the decision the forecast feeds.
   Metric: MASE (scale-free) plus MAE (in real units). Avoid MAPE when the target has
   zeros or near-zeros. For quantile forecasts use pinball loss.
2. **Check the data.** Sort by time, no duplicate timestamps, never fill missing values
   silently, note gaps, and confirm the dates parse the way you think (`--date-format
   %d-%m-%Y` for day-first dates). Leakage check: every feature must be known at forecast time
   (lagged or as-of values only), and scalers/encoders are fit on the training window only.
3. **Baselines first.** Run `scripts/backtest.py` with no candidate. It scores naive,
   seasonal naive and drift over several forecast origins. If the horizon is long or the
   data repeats yearly, give every natural season in one run (`--season 7 364` for daily
   data). Each value adds a seasonal naive, all are scored on the same origins, and MASE is
   scaled by the first value. A longer season needs a longer history, so short series lose
   origins (see the `origins:` line) or are skipped. A candidate that beats only the
   short-season baseline has not beaten the best baseline.
4. **Candidate.** Write `forecast(train, h)` in its own file, return `h` values, and run
   the script again with `--candidate`. Pass several files to compare models on the same windows,
   the table names them after the files. Start simple (ETS/ARIMA, or a GBM on lag features)
   before anything heavier.
5. **Read the verdict.** The script prints whether the candidate beats the best baseline.
   If it does not, say so and recommend the baseline. A gap under 1% prints "ties the
   baseline" and is not a win. On one series with 10 or more origins whose windows do not
   overlap (`--step` at least the horizon), a gap a paired test cannot tell from noise
   prints "ties" too. If you call a gap noise, or the script reports a tie, deliver the
   baseline's forecast, not the candidate's. If only a few origins fit, bigger gaps can
   still be noise: raise `--origins`, or shrink `--step`, which adds origins but turns
   the paired test off.
6. **Uncertainty.** If the user needs ranges, add `forecast_interval(train, h, level)` to the
   candidate file, returning `(lower, upper)`, and run with `--level 80 95`. The script prints
   the share of test points inside each interval and the mean width. Coverage far below the
   level means the ranges are too narrow, far above means too wide.
7. **Report.** Table of MAE and MASE per model, number of origins (and series scored versus
   skipped), MASE by horizon step (`--by-horizon`), and the caveats (gaps, short history,
   structural breaks). Also say what the backtest could not test: a stretch of the forecast
   window that no backtest window covers (a holiday peak, for example). And say how the
   model was chosen: if you tried several models or settings on the same windows, its error
   is optimistic; if you tried only one, say that.

## Usage

```bash
python3 scripts/backtest.py data.csv --date date --target sales --horizon 28 --season 7 --origins 8
python3 scripts/backtest.py data.csv --date date --target sales --horizon 28 --season 7 \
  --candidate my_model.py --by-horizon
# several models in one table, same windows, named after their files
python3 scripts/backtest.py data.csv --date date --target sales --horizon 28 --season 7 \
  --candidate ets.py harmonic.py lightgbm.py
# long horizon: give the yearly season too, every baseline is scored on the same origins
python3 scripts/backtest.py data.csv --date date --target sales --horizon 90 --season 7 364
# interval coverage: my_model.py also defines forecast_interval(train, h, level), see examples/ets_monthly.py
python3 scripts/backtest.py data.csv --date date --target sales --horizon 28 --season 7 \
  --candidate my_model.py --level 80 95
# many stores or items: name the columns that identify one series
python3 scripts/backtest.py data.csv --date date --target sales --id store item \
  --horizon 28 --season 7 --max-series 50 --candidate my_model.py
# rolling window (last 730 points at every origin) and volume-weighted averages over series
python3 scripts/backtest.py data.csv --date date --target sales --id store item \
  --horizon 28 --season 7 --window 730 --weight volume
```

Candidate file example (needs `statsmodels`):

```python
# my_model.py
from statsmodels.tsa.holtwinters import ExponentialSmoothing

def forecast(train, h):  # train is a pd.Series with a DatetimeIndex
    return ExponentialSmoothing(train, trend="add", seasonal="add", seasonal_periods=7).fit().forecast(h)
```

## Limits

- Many series: `--id` scores each series on its own, then averages MASE with equal weight
  per series (`--weight volume` weights by mean absolute target value in the scored windows instead) and
  counts the series where the candidate beats the best baseline. Series that are too short or have missing
  values are skipped and counted in the output. `--max-series N` takes the first N series in id order, not a
  random sample.
- The expanding window is the default. `--window N` switches to a rolling window of N points.
- MASE scales by the seasonal-naive error of everything before the origin, also with `--window`. An origin
  where that error is zero is left out. A series where it is zero before every origin (a flat one, or one that
  repeats its season exactly) gets no MASE and is listed on a line of its own with each model's MAE.
- Needs Python 3 with pandas and numpy.
Files in this package (17)
  • .gitignore 1 KB
  • LICENSE 1 KB
  • README.md 17 KB
  • SKILL.md 6 KB
  • assets/baseline-vs-model-dark.svg 3 KB
  • assets/baseline-vs-model-light.svg 3 KB
  • assets/rolling-origin-dark.svg 3 KB
  • assets/rolling-origin-light.svg 3 KB
  • assets/social-preview.png 105 KB
  • assets/social-preview.svg 3 KB
  • examples/ets_daily.py 1 KB
  • examples/ets_monthly.py 1 KB
  • examples/ets_weekly.py 1 KB
  • examples/prophet_daily.py 1 KB
  • examples/yearly_harmonic.py 1 KB
  • scripts/backtest.py 18 KB
  • scripts/test_backtest.py 24 KB

Versions

The database has no other skills named forecast-backtest.

Database snapshot: 13.11.2026 · package version 4530108ab3b4 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90skforecast-ai-forecasting
    Forecast time series stored in CSV files with the tools of the skforecast-ai MCP server (profile, plan, create_cv, backtest, compare, forecast). Use when asked to forecast, backtest or compare forecasting models on tabular time series and the skforecast-ai server is connected.…
  • 90skforecast-ai-forecasting
    Forecast time series stored in CSV files with the tools of the skforecast-ai MCP server (profile, plan, create_cv, backtest, compare, forecast). Use when asked to forecast, backtest or compare forecasting models on tabular time series and the skforecast-ai server is connected.…
  • 95demand-forecasting
    When the user wants to forecast demand, build forecasting models, or improve forecast accuracy. Also use when the user mentions "demand planning," "sales forecasting," "time series," "forecast accuracy," "demand sensing," "statistical forecasting," or "predictive analytics." For…
  • 100forecasting-multiple-series
    Forecasts multiple time series simultaneously using a global model with ForecasterRecursiveMultiSeries or ForecasterDirectMultiVariate. Covers data formats, encoding, per-series transformers, and multi-series backtesting. Use when the user has two or more related time series.
  • 100time-series-forecasting
    Forecast or predict future values of one or many time series (sales, demand, traffic, revenue per period), e.g. "predict tomorrow's / next day's / next week's / next month's value", or find out how forecastable they are. Use it whenever the data is measured period after period…
  • 100forecast-accuracy-review
    Evaluate demand-forecast quality honestly - WMAPE, bias and Forecast Value Added against a naive benchmark over a rolling-origin backtest. Use when the user mentions forecast accuracy, MAPE, demand planning performance, tahmin doğruluğu, talep tahmini, or asks whether a…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.