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] optimized historical_forecasts has incorrect time indices under certain conditions #2633

Closed
MattiasDC opened this issue Dec 26, 2024 · 1 comment · Fixed by #2634
Closed
Labels
bug Something isn't working

Comments

@MattiasDC
Copy link
Contributor

Describe the bug
When generating a historical forecast using regression model and last point forecasting on a model with output_chunk_shift > 0, time indices are not shifted according to the output_chunk_shift. This is only the case when doing an 'optimized' historical forecast (when you get into darts.utils.historical_forecasts.optimized_historical_forecasts_regression._optimized_historical_forecasts_last_points_only.

To Reproduce

from darts.datasets import AirPassengersDataset
from darts.models import RegressionModel

series = AirPassengersDataset().load()

model = RegressionModel(lags=20, output_chunk_shift=5)
model.fit(series)

historical = model.historical_forecasts(series=series,
                                        retrain=False,
                                        forecast_horizon=1)


series.plot(label="actual")
historical.plot(label="historical")

This will plot this image:
image

Expected behavior
The returned historical series don´t have their time index shifted respecting the output chunk shift.
The following result would be correct:
image

System (please complete the following information):

  • Python version: 3.12
  • darts version 0.31.0

Additional context
I will create a PR for this.
I've also inspected darts.utils.historical_forecasts.optimized_historical_forecasts_regression._optimized_historical_forecasts_all_points, which does seem to always take into account the output_chunk_shift unconditionally. I also looked at darts.utils.historical_forecasts.optimized_historical_forecasts_tocrch._optimized_historical_forecasts, which also doesn´t seem affected.

@dennisbader
Copy link
Collaborator

Thanks a lot @MattiasDC for opening this issue, the well documented report and the PR 🚀 🚀 🚀
Let's continue this thread in #2634

@madtoinou madtoinou removed the triage Issue waiting for triaging label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants