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/add fit/predict_kwargs argument to historical_forecasts #2050

Merged
merged 35 commits into from
Nov 16, 2023

Conversation

madtoinou
Copy link
Collaborator

@madtoinou madtoinou commented Nov 3, 2023

Fixes #1767.

Summary

  • Added fit_kwargs and predict_kwargs argument to historical_forecasts, backtest and gridsearch
  • Added some logic in fit_predict and predict_wrapper to pass the arguments to fit()/predict() only when it's supported (based on method signature)

Other Information

Rely on python to complain when unsupported or duplicated arguments are provided

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.

Wouldn't this be a great opportunity to add fit and predict kwargs to historical forecasts? :)

@madtoinou madtoinou changed the title Fix/add num_loader_workers argument to historical_forecasts Fix/add fit/predict_kwargs argument to historical_forecasts Nov 3, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

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

Files Coverage Δ
darts/models/forecasting/forecasting_model.py 94.87% <100.00%> (+0.49%) ⬆️
darts/models/forecasting/regression_model.py 96.76% <ø> (ø)
...arts/models/forecasting/torch_forecasting_model.py 90.76% <ø> (-0.03%) ⬇️
...casts/optimized_historical_forecasts_regression.py 97.22% <ø> (ø)
..._forecasts/optimized_historical_forecasts_torch.py 94.87% <100.00%> (+0.27%) ⬆️
darts/utils/historical_forecasts/utils.py 93.85% <93.33%> (-0.11%) ⬇️

... and 5 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 like a great start @madtoinou 🚀

I added a couple of suggestions on how we could simplify the kwargs handling and the fit/predict wrappers.
We can let python handle some of edge cases, and potentially, we can adapt the fit/predict wrappers to generalize over all models (and reduce code).

darts/models/utils.py Outdated Show resolved Hide resolved
darts/models/utils.py Outdated 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/models/forecasting/forecasting_model.py Outdated Show resolved Hide resolved
darts/models/forecasting/torch_forecasting_model.py Outdated Show resolved Hide resolved
darts/models/forecasting/regression_model.py Outdated Show resolved Hide resolved
darts/models/forecasting/torch_forecasting_model.py Outdated Show resolved Hide resolved
darts/models/forecasting/regression_model.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.

Looking really good now, thanks @madtoinou 🚀
Just some minor suggestions

@madtoinou
Copy link
Collaborator Author

Updated the PR, handling of the fit/predict_kwargs was improved and some tests were added.

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.

Very nice, this looks awesome 🚀
This time really only minimal suggestions, we can merge soon.

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 Outdated Show resolved Hide resolved
darts/utils/historical_forecasts/utils.py Outdated Show resolved Hide resolved
darts/models/forecasting/forecasting_model.py Show resolved Hide resolved
Co-authored-by: Dennis Bader <dennis.bader@gmx.ch>
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.

Everything looks good now, great job @madtoinou 🚀

@dennisbader dennisbader merged commit c8f5948 into master Nov 16, 2023
8 of 9 checks passed
@dennisbader dennisbader deleted the fix/hfc_num_loader_workers branch November 16, 2023 10:44
@pfk-beta
Copy link

Can't wait for release

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.

[Minor BUG] num_workers when calling predict/historical_forecasts of specific models
4 participants