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] NaiveEnsemble not fitting with future_covariates #1800

Closed
leemstirling opened this issue May 26, 2023 · 1 comment
Closed

[BUG] NaiveEnsemble not fitting with future_covariates #1800

leemstirling opened this issue May 26, 2023 · 1 comment
Labels
bug Something isn't working triage Issue waiting for triaging

Comments

@leemstirling
Copy link

Describe the bug
Fitting a standalone ARIMA model with covariates works but when the ARIMA model is part of a NaiveEnsemble is does not work.

To Reproduce

>>> from darts.utils.timeseries_generation import gaussian_timeseries
>>> from darts.utils.timeseries_generation import sine_timeseries
>>> FORECAST_LENGTH = 30

>>> # toy timeseries
>>> ts = gaussian_timeseries(mean=100, std=15, start=pd.Timestamp('2021-01-01'), length=365)

>>> # toy covariate
>>> covariates = sine_timeseries(start=ts.start_time(), length=365+FORECAST_LENGTH, value_y_offset=100, value_frequency=0.1)

>>> # fit standalone ARIMA model
>>> arima_model = ARIMA(p=1, q=1, d=1, random_state=1255)
>>> arima_model.supports_future_covariates
True
>>> arima_model.fit(ts, future_covariates=covariates)
>>> arima_preds = arima_model.predict(FORECAST_LENGTH, future_covariates=covariates)

>>> # fit ARIMA model as part of a NaiveEnsemble
>>> models = [
    ARIMA(p=1, q=1, d=1, random_state=1255),
    NaiveDrift(),
]

>>> ensemble_model = NaiveEnsembleModel(models=models)
>>> ensemble_model.supports_future_covariates
True
>>> ensemble_model.fit(ts, future_covariates=covariates)
>>> ensemble_model_preds = ensemble_model.predict(FORECAST_LENGTH, future_covariates=covariates)
ERROR:main_logger:ValueError: The model has been trained without `future_covariates` variable, but the `future_covariates` parameter provided to `predict()` is not None.

Expected behavior
ensemble_model.predict(30, future_covariates=covariates) should return the average values for the separately fit NaiveDrift and ARIMA models. Instead it throws an error, claiming that the ensemble_model was fit without future_covariates (when it actually was).

System:

  • Python version: 3.11
  • darts version: 0.24.0

Additional context
Currently working around this by creating a NaiveEnsemble of models that don't use future_covariates and separate, individual models for those that do use future_covariates. I then reconstitute the average of all models with a few extra lines of code. Would be great to know whether this can be fixed (or if this isn't possible and I've misunderstood the NaiveEnsemble's capability 🤣).

@leemstirling leemstirling added bug Something isn't working triage Issue waiting for triaging labels May 26, 2023
@dennisbader
Copy link
Collaborator

Hi @leemstirling, and thanks for writing. We recently fixed this in #1745 and will be part of the next darts release.

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

No branches or pull requests

3 participants