#11317·sktime

[BUG] HolidayFeatures: dummy columns depend on the transformed dates, so forecasting pipelines break or silently use the wrong holiday

Author: RobKueblerCreated Sep 27, 2026Updated Sep 27, 2026

Describe the bug

HolidayFeatures is stateless (fit_is_empty=True). Each transform call creates dummy columns only for the holidays that occur in the dates it receives. In a ForecastingPipeline, the transformer sees the training index in fit and only the forecasting horizon in predict, which usually contain different holidays. The downstream forecaster therefore gets different columns in predict than in fit.

Depending on the forecaster, this either raises an error or gives wrong forecasts with no warning:

  • Silent: forecasters that match exogenous columns by position (SARIMAX, UnobservedComponents, pmdarima ARIMA). If the horizon has the same number of holiday columns as training but different holidays, the coefficient learned for one holiday is applied to another. In the SARIMAX example below, the Easter Monday drop is forecast on Christmas Day.
  • Error: if the horizon has fewer holiday columns than training, which is the normal case with short horizons (statsmodels/pmdarima: Provided exogenous values are not of the appropriate shape, Prophet: Regressor 'Easter Monday' missing from dataframe, YfromX: Input X contains NaN, make_reduction: numpy concatenation error).

The categories of the categorical output (return_categorical=True) have the same problem. Only return_indicator has stable columns.

To Reproduce

Silent wrong forecast with SARIMAX. The model never saw a Christmas, but it forecasts the Easter Monday drop on Christmas Day:

python
from datetime import date

import numpy as np
import pandas as pd

from sktime.forecasting.compose import ForecastingPipeline
from sktime.forecasting.sarimax import SARIMAX
from sktime.transformations.holiday import HolidayFeatures

calendar = {date(2024, 4, 1): "Easter Monday", date(2024, 12, 25): "Christmas"}
index = pd.date_range("2024-01-02", "2024-12-27", freq="D")
y = pd.Series(100 + np.random.default_rng(0).normal(0, 1, len(index)), index=index)
y["2024-04-01"] -= 50  # Easter Monday: sales drop
X = pd.DataFrame({"const": 1.0}, index=index)  # only the index is used

forecaster = ForecastingPipeline([HolidayFeatures(calendar), SARIMAX(order=(1, 0, 0))])
forecaster.fit(y[:"2024-12-20"], X=X[:"2024-12-20"])  # features: [Easter Monday]
y_pred = forecaster.predict(fh=list(range(1, 8)), X=X["2024-12-21":])  # features: [Christmas]
print(y_pred.round(1))
2024-12-21    100.0
2024-12-22    100.0
2024-12-23    100.0
2024-12-24    100.0
2024-12-25     50.1   <- Easter Monday's -50, applied to Christmas
2024-12-26    100.0
2024-12-27    100.0

The columns directly:

python
t = HolidayFeatures(calendar)
t.fit_transform(X[:"2024-12-20"]).columns.tolist()  # ['Easter Monday']
t.transform(X["2024-12-21":]).columns.tolist()      # ['Christmas']

Affected forecasters

I ran ForecastingPipeline([HolidayFeatures(calendar), forecaster]) for both cases on synthetic daily data (Easter Monday -50, Christmas +40), predicting Christmas week. The table shows the forecast for Dec 25 minus the forecast for Dec 21:

  • A: two years of history. Training has [Christmas, Easter Monday], the horizon only [Christmas].
  • B: one year of history ending on Dec 20. Training has only [Easter Monday], the horizon only [Christmas] (the example above).

The "stable columns" column shows the same run with the horizon features reindexed to the training columns (missing columns filled with 0), which is the behavior proposed below. Correct values are about +40 in A and 0 in B.

forecaster A (current) A (stable columns) B (current) B (stable columns)
SARIMAX error (exog shape) +41.1 -50.9, silent +0.0
UnobservedComponents error (exog shape) +41.1 -50.9, silent +0.0
ARIMA (pmdarima) error (exog shape) +41.1 -50.9, silent +0.0
Prophet error (missing regressor) +41.0 error (missing regressor) +0.2
RecursiveReductionForecaster(LinearRegression()) error (NaN) +41.2 error (feature names) +0.1
YfromX(LinearRegression()) error (NaN) +41.1 error (feature names) +0.0
make_reduction(LinearRegression()) error (concatenation) n/a* runs n/a*

* make_reduction returns RecursiveTabularRegressionForecaster, which by design only uses lagged X (t-window_length .. t-1, see _sliding_window_transform_local), so the dummy for Dec 25 can't affect the forecast for Dec 25. It still crashes in case A. In case B the shapes match, so it runs with the same position mismatch as SARIMAX: the lagged Christmas column is used where the Easter Monday column was during fitting.

Expected behavior

transform returns the same columns, in the same order, as in fit, whatever dates it is called on. This is how sklearn's OneHotEncoder behaves:

  • A holiday seen in fit but absent from the dates being transformed gets a column of 0s.
  • A holiday not seen in fit is dropped from the dummies and labeled no_holiday in the categorical output, since the downstream model has no parameter for it.

Proposed fix

  • Set fit_is_empty=False.
  • In _fit, store the categories generated for the training index.
  • In _transform, cast the categorical column to those stored categories (unseen labels become no_holiday) and reindex the dummies with reindex(columns=..., fill_value=0).

This is a small change and I'm happy to open a PR for it.

It does change behavior: code that calls transform on new data without refitting and expects columns for only the holidays present in that data would get different columns.

Additional context

  • Found while working on #11313 (offset labels). It happens even more often there: offset labels create one column per holiday and offset, and each of those columns covers only a few dates.
  • Separate problem found along the way: ForecastingPipeline([HolidayFeatures(...), StatsForecastAutoARIMA()]) fails even with stable columns, with xreg should be a float array, because the dummies are int. With the dummies cast to float it works (A: +40.9, B: +0.0).

Versions

sktime main at c69606f79, statsmodels 0.15.0, Python 3.12 (Prophet, pmdarima, statsforecast: latest from PyPI on 2026-09-27)