Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NaiveEnsembleModel does not work with NaiveSeasonal #1595

Closed
turbotimon opened this issue Feb 24, 2023 · 1 comment · Fixed by #1616
Closed

[BUG] NaiveEnsembleModel does not work with NaiveSeasonal #1595

turbotimon opened this issue Feb 24, 2023 · 1 comment · Fixed by #1616
Labels
bug Something isn't working triage Issue waiting for triaging

Comments

@turbotimon
Copy link
Contributor

turbotimon commented Feb 24, 2023

Describe the bug
NaiveEnsembleModel with a NaiveSeasonal with k>3 almost allways gives me an ValueError.
I dont' found a way to prevent this

To Reproduce

from darts import TimeSeries
from darts.models.forecasting.baselines import NaiveMean, NaiveSeasonal, NaiveEnsembleModel
import numpy as np

y = TimeSeries.from_values(np.arange(100))

# NaiveSeasonal alone works fine (no error)
naive_seasonal = NaiveSeasonal(7)
naive_seasonal.fit(y[:50])
naive_seasonal.backtest(y);

# However inside an Ensemble, it gives me a ValueError
naive_ensemble= NaiveEnsembleModel([NaiveMean(), NaiveSeasonal(7)])
naive_ensemble.fit(y[:50])
naive_ensemble.backtest(y);
# ValueError: Train series only contains 3 elements but Naive seasonal model, with K=7 model requires at least 7 entries

# Even if the inputs are dividable by 7 its an ValueError
naive_ensemble= NaiveEnsembleModel([NaiveMean(), NaiveSeasonal(7)])
naive_ensemble.fit(y[:49])
naive_ensemble.backtest(y[:98]);
# ValueError: Train series only contains 3 elements but Naive seasonal model, with K=7 model requires at least 7 entries

Expected behavior
It should work as it works alone

System (please complete the following information):

  • Python 3.8.10
  • darts 0.23.1

Additional context

  • As fare as i figured out, it goes down to the EnsembleModel Base Class
  • It is may solvable by taking into account the extreme_lags proberty of each model inside of the ensemble
  • However, it is strange to me, that it is also happening when the inputs are dividable by k=7. So i don't even have a workaround at the time! In fact, i didn't found any length of y [0..100] or k>3 so that it works
@turbotimon turbotimon added bug Something isn't working triage Issue waiting for triaging labels Feb 24, 2023
@JanFidor
Copy link
Contributor

JanFidor commented Mar 4, 2023

Hi @turbotimon, great find, the error is thrown for ensemble .historical_forecasts() and by extension .backtest() if it has any model with input_chunk_length > 1 or lags looking further than -1. I think I found the cause, when calling historical_forecasts and iterating over historical_series, minimum length is set incorrectly, after digging around with a debugger I found out that the Ensemble's max target lag (in extreme_lags) is set to 1 while it should've taken into account it's models extreme lags. I'll make a quick PR @dennisbader @hrzn @madtoinou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue waiting for triaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants