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

Merged
merged 56 commits into from
Nov 25, 2024
Merged

Feat/scalar with window #2529

merged 56 commits into from
Nov 25, 2024

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
Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 92.98246% with 8 lines in your changes missing coverage. Please review.

Project coverage is 94.10%. Comparing base (d103a05) to head (a633564).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
darts/models/forecasting/forecasting_model.py 88.46% 3 Missing ⚠️
darts/utils/historical_forecasts/utils.py 94.33% 3 Missing ⚠️
...essing/transformers/invertible_data_transformer.py 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2529      +/-   ##
==========================================
- Coverage   94.15%   94.10%   -0.05%     
==========================================
  Files         139      139              
  Lines       14890    14992     +102     
==========================================
+ Hits        14019    14108      +89     
- Misses        871      884      +13     

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


🚨 Try these New Features:

Copy link

review-notebook-app bot commented Nov 12, 2024

View / edit / reply to this conversation on ReviewNB

dennisbader commented on 2024-11-12T09:30:45Z
----------------------------------------------------------------

Line #8.        "enable_optimization": False,

maybe remove?


madtoinou commented on 2024-11-12T10:51:33Z
----------------------------------------------------------------

I added it to hide the warnings, but I don't mind removing it.

Copy link

review-notebook-app bot commented Nov 12, 2024

View / edit / reply to this conversation on ReviewNB

dennisbader commented on 2024-11-12T09:30:46Z
----------------------------------------------------------------

Here I think it would be great to leave the example without data_transformers in historical_forecasts, and then show in a next example how it's done with the transformers. Also:

  • The plot is identical to before, shouldn't it have some diffs at least?
  • we should really transform the series as well

madtoinou commented on 2024-11-12T11:13:35Z
----------------------------------------------------------------

Updated the notebook; two examples (one with, one without the auto-scaling) while minimizing the changes

Copy link
Collaborator Author

I added it to hide the warnings, but I don't mind removing it.


View entire conversation on ReviewNB

Copy link
Collaborator Author

Updated the notebook; two examples (one with, one without the auto-scaling) while minimizing the changes


View entire conversation on ReviewNB

Copy link

review-notebook-app bot commented Nov 14, 2024

View / edit / reply to this conversation on ReviewNB

dennisbader commented on 2024-11-14T14:59:43Z
----------------------------------------------------------------

I think the note about parallelization was removed, let's add it back again?


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.

This looks really good @madtoinou 🚀

I added a couple of suggestions, and two things which we should add:

  • support data transformers in residuals
  • support pre-trained data transformers regardless of global_fit

darts/models/forecasting/forecasting_model.py Outdated Show resolved Hide resolved
darts/models/forecasting/forecasting_model.py Outdated Show resolved Hide resolved
darts/models/forecasting/forecasting_model.py Show resolved Hide resolved
darts/models/forecasting/forecasting_model.py Show resolved Hide resolved
darts/models/forecasting/forecasting_model.py Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
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.

Beautiful 😍 I pushed some minor changes:

  • adapt the docs a bit here and there
  • renamed idx_series to series_idx
  • converted transform() of fitted_values (in gridsearch) to inverse_transform() (should be inverse transform I think ;) )

There is one last change that we throw a warning instead of an error when global_fit=True and len(series)>1

darts/utils/historical_forecasts/utils.py Outdated Show resolved Hide resolved
darts/utils/historical_forecasts/utils.py Outdated Show resolved Hide resolved
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.

Great work @madtoinou and @JanFidor 🚀 Thanks for all the work!

@dennisbader dennisbader merged commit 39cf38c into master Nov 25, 2024
9 checks passed
@dennisbader dennisbader deleted the feat/scalar-with-window branch November 25, 2024 10:25
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