Programming

Compare forecast horizons from the same origins with DIY AutoML

When I compare one-step and five-step forecasts, I start by checking where each forecast was made. With a short holdout, the five-step forecast can only be evaluated from earlier origins. Using the same origins for each horizon makes it easier to see which part of the holdout each score describes. The Python package behind DIY AutoML, UC_AutoMaiL, is now available on the main PyPI index as 0.4.1a2. This example uses a small synthetic series to show how the origins, errors, and interval coverage

When I compare one-step and five-step forecasts, I start by checking where each forecast was made. With a short holdout, the five-step forecast can only be evaluated from earlier origins. Using the same origins for each horizon makes it easier to see which part of the holdout each score describes.

The Python package behind DIY AutoML, UC_AutoMaiL, is now available on the main PyPI index as 0.4.1a2. This example uses a small synthetic series to show how the origins, errors, and interval coverage appear in the saved workbook. The earlier walkthrough used the TestPyPI alpha for an Iris classification example. PyPI release · Earlier Iris walkthrough

Run a comparison on a seasonal series

Use a fresh folder and a Python 3.12 or newer virtual environment.

python -m pip install "uc-automail==0.4.1a2"
python -m uc_automail --version

Save this example as horizons_demo.py and run python horizons_demo.py. The input has a four-observation cycle with a small amount of noise. The candidates include a seasonal naïve forecast and a local-level Kalman forecast, alongside a last-value baseline.

import numpy as np
import pandas as pd
import uc_automail as uc_al

rng = np.random.default_rng(42)
steps = np.arange(160)
season = np.tile([10.0, 20.0, 30.0, 40.0], 40)
values = season + rng.normal(0, 0.5, len(steps))
pd.DataFrame({"step": steps, "value": values}).to_csv("series.csv", index=False)

out = uc_al.forecast_horizons_csv(
    "series.csv", "runs/horizons-demo",
    time_column="step", value_column="value",
    horizons=(1, 3, 5), holdout_rows=24,
    models=("seasonal", "kalman"), season_length=4,
    interval_method="adaptive", selection_tolerance=0.02,
)
print(out / "report.xlsx")

The last 24 observations form the holdout. The longest forecast goes five steps ahead, so the comparison uses 20 common origins. Within each horizon, the models are evaluated on the same observations. Use a new output path when rerunning the script. Forecast origins and holdout rules

Read the error and interval results together

In this run, the seasonal forecast was selected for each horizon. These are its results on the holdout.

Steps ahead Holdout RMSE Inside the prediction interval
1 1.007 12 of 20
3 1.032 16 of 20
5 0.665 12 of 20

The four-observation cycle was built into this example. The five-step forecast had the lowest RMSE in this run. Its interval covered 12 of 20 observations, the same count as the one-step forecast.

In report.xlsx, start with Selection for the chosen models and Scores for holdout error, coverage, and interval width. Forecasts links each prediction to its origin and target row. Selection_Band records how the 2% tolerance was applied during selection. Interval_Evidence records the completed forecast paths used to update the intervals. Workbook fields and evaluation design

AI was used to draft and edit this article.