Summary
HyperTreeSTL(type="default") fails during forecasting when the forecast horizon is shorter than the learned trend smoothing window / seasonal period. I hit this with fcst_h=3 on a monthly grocery-price example.
Reproduction
Train a default HyperTreeSTL model and forecast with a short horizon, for example:
from hypertrees.models import HyperTreeSTL
fcst_h = 3
model = HyperTreeSTL(period=12, num_seasonal_components=2, freq="M", fcst_h=fcst_h)
model.train(
lgb_params={"learning_rate": 0.05},
num_iterations=8,
train_data=train_one,
validation=False,
)
model.forecast(test_data=test_one)
where test_one has exactly 3 rows and includes the required series_id, date, time, and feature columns.
Observed behavior
Forecasting raises from the default STL forward pass:
RuntimeError: Forecasting not successful: Argument #4: Padding size should be less than the corresponding input dimension
The immediate source is torch.nn.functional.pad(..., mode="reflect") in _forward_default. With fcst_h=3, the input length is 3 but the smoothing window can produce padding such as (7, 7).
There is also a second short-horizon edge case in seasonal centering: when T < period, the existing reflected tail may not be long enough to pad to a full seasonal cycle before view(C, m, N).
Expected behavior
HyperTreeSTL(type="default") should support short forecast horizons such as fcst_h=3 and fcst_h=1, or fail earlier with a clear validation error. Since the model already accepts any positive fcst_h, handling short horizons seems preferable.
Suggested fix
A local patch fixes this by:
- capping the default smoothing window by the actual sequence length so reflect padding satisfies
pad < T
- bypassing smoothing for
T <= 1
- repeating reflected seasonal values enough times when padding
T < period to a full seasonal cycle
- adding regression tests for 3-step and 1-step horizons
I can open a PR with that patch.
Summary
HyperTreeSTL(type="default")fails during forecasting when the forecast horizon is shorter than the learned trend smoothing window / seasonal period. I hit this withfcst_h=3on a monthly grocery-price example.Reproduction
Train a default
HyperTreeSTLmodel and forecast with a short horizon, for example:where
test_onehas exactly 3 rows and includes the requiredseries_id,date,time, and feature columns.Observed behavior
Forecasting raises from the default STL forward pass:
The immediate source is
torch.nn.functional.pad(..., mode="reflect")in_forward_default. Withfcst_h=3, the input length is 3 but the smoothing window can produce padding such as(7, 7).There is also a second short-horizon edge case in seasonal centering: when
T < period, the existing reflected tail may not be long enough to pad to a full seasonal cycle beforeview(C, m, N).Expected behavior
HyperTreeSTL(type="default")should support short forecast horizons such asfcst_h=3andfcst_h=1, or fail earlier with a clear validation error. Since the model already accepts any positivefcst_h, handling short horizons seems preferable.Suggested fix
A local patch fixes this by:
pad < TT <= 1T < periodto a full seasonal cycleI can open a PR with that patch.