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

Fix/optimized historical forecast with component specific lags #2040

Merged
merged 4 commits into from
Oct 28, 2023

Conversation

madtoinou
Copy link
Collaborator

Summary

Optimized historical forecasts with regression models would raise an exception when using component-specific lags with different number of lags because create_lagged_prediction_data() was calling model.lags.get() instead of the dedicated method model._get_lags() which properly accounts for the component-specific lags.

Other Information

Code snippet to reproduce the bug:

from darts.models import LinearRegressionModel
from darts.datasets import AirPassengersDataset

# future_cov components: darts_enc_fc_cyc_month_sin and darts_enc_fc_cyc_month_cos
model = LinearRegressionModel(
    lags=3,
    lags_future_covariates={'default_lags':[-4, -2],
                            'darts_enc_fc_cyc_month_sin':[-1]
                           },
    add_encoders={
        "cyclic": {"future": ["month"]},
    }
)

series = AirPassengersDataset().load()
model.fit(series)
model.historical_forecasts(series=series, retrain=False)

@codecov-commenter
Copy link

codecov-commenter commented Oct 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files Coverage Δ
darts/models/forecasting/regression_model.py 96.50% <100.00%> (ø)
...orical_forecasts/optimized_historical_forecasts.py 97.56% <ø> (ø)

... and 6 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

Copy link
Collaborator

@dennisbader dennisbader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for fixing this so quickly @madtoinou 🚀

I added a test, ready to be merged now 💯

@dennisbader dennisbader merged commit 039d898 into master Oct 28, 2023
9 checks passed
@dennisbader dennisbader deleted the fix/opti_hc_components_lags branch October 28, 2023 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

3 participants