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

Feat/scalar with window #2529

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open

Feat/scalar with window #2529

wants to merge 33 commits into from

Conversation

madtoinou
Copy link
Collaborator

@madtoinou madtoinou commented Sep 12, 2024

Checklist before merging this PR:

  • Mentioned all issues that this PR fixes or addresses.
  • Summarized the updates of this PR under Summary.
  • Added an entry under Unreleased in the Changelog.

Fixes #1540.

Summary

  • Possibility to pass Scaler/Pipeline to historical_forecasts(), backtest() and gridsearch() to avoid data-leakage
    • When enable_optimization=True, the Pipeline must already be fitted (when applicable), all the series are transformed in one pass
    • Pipeline are systematically fitted and applied to the series between each forecast horizon (regardless of the retrain parameter value)

Other Information

The input series to these methods must always be "un-processed" when providing data_transformers in order to avoid "double scaling" of the series.

This PR is based on #2021.

JanFidor and others added 23 commits August 25, 2023 22:50
…th-window

# Conflicts:
#	darts/models/forecasting/forecasting_model.py
#	darts/models/forecasting/regression_model.py
#	darts/utils/historical_forecasts/optimized_historical_forecasts_regression.py
#	darts/utils/historical_forecasts/utils.py
Co-authored-by: Dennis Bader <dennis.bader@gmx.ch>
Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 92.64706% with 5 lines in your changes missing coverage. Please review.

Project coverage is 93.84%. Comparing base (b41be28) to head (912e0d2).

Files with missing lines Patch % Lines
darts/utils/historical_forecasts/utils.py 91.89% 3 Missing ⚠️
darts/models/forecasting/forecasting_model.py 90.90% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2529      +/-   ##
==========================================
- Coverage   93.86%   93.84%   -0.02%     
==========================================
  Files         139      139              
  Lines       14855    14906      +51     
==========================================
+ Hits        13943    13989      +46     
- Misses        912      917       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Thanks a lot @madtoinou this looks really great 🚀 I like the approach with the Pipeline instead of Transformers :)

Had some remarks and suggestions, we can discuss later.

darts/dataprocessing/pipeline.py Show resolved Hide resolved
darts/models/forecasting/forecasting_model.py Show resolved Hide resolved
darts/models/forecasting/forecasting_model.py Outdated Show resolved Hide resolved
darts/models/forecasting/forecasting_model.py Outdated Show resolved Hide resolved
darts/utils/historical_forecasts/utils.py Outdated Show resolved Hide resolved
[True, False],
),
)
def test_historical_forecasts_with_scaler(self, params):
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice one 👍 :)
Could you check for 2 historical forecast iterations? Also checking last_points_only=False, and enable_optimization=True would be important.

[True, False],
),
)
def test_historical_forecasts_with_scaler(self, params):
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we move this test into darts/tests/models/forecasting/test_historical_forecasts.py and generalize for local, torch, and regression models?

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Scaler with rolling/expanding window to eliminate look ahead bias
3 participants