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 the sample_weights bug #2445

Merged
merged 8 commits into from
Jul 5, 2024

Conversation

cnhwl
Copy link
Contributor

@cnhwl cnhwl commented Jul 3, 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 #2439.

Summary

fixes the sample_weights bug by making conditional judgement on whether sample_weights is none and whether the parameter sample_weights exists in the model fit method.

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.80%. Comparing base (e8b5daa) to head (44aa8a2).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2445      +/-   ##
==========================================
- Coverage   93.80%   93.80%   -0.01%     
==========================================
  Files         139      139              
  Lines       14680    14678       -2     
==========================================
- Hits        13771    13768       -3     
- Misses        909      910       +1     

☔ 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 for the fix and the contribution @cnhwl 🚀 It's highly appreciated :)

I just had a minor suggestion for code. And there are some things that we should address before merging:

  • add a unit test to darts/tests/models/forecasting/test_regression_models.py that checks that it works as expected with models that don't support sample weights
  • in darts/utils/multioutput.py - MultiOutputRegressor.fit() we currently raise an error if the user provided sample_weight but the model doesn't support it. The MultiOutputRegressor is applied if we need to predict more than one target component and / or output_chunk_length > 1. Ideally, we should have the same behavior there as well. So if you can replace raising an error with a warning, that should be fine. (these lines here)
  • can you add an etry to our CHANGELOG.md under the Unreleased / Fixed section?

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.

Thanks for the updates @cnhwl 🚀

I took the liberty to apply the last open points directly (e.g., adaptions to MultiOutputRegressor, and adding the KNeighborsRegressor only to the sample weights tests).

Looks great now! We can merge after all tests have passed 💯

@cnhwl
Copy link
Contributor Author

cnhwl commented Jul 5, 2024

Thank you so much! @dennisbader ❤️

I have benefited a lot from your code. It's been a pleasure working with you on this merge.

Looking forward to contributing more to the darts library! 🚀

@dennisbader dennisbader merged commit 9d89bff into unit8co:master Jul 5, 2024
9 checks passed
@cnhwl cnhwl deleted the fix/sample_weights_issue branch December 3, 2024 02:02
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.

[BUG] Models that fit method do not support the parameter sample_weights cannot be fitted
2 participants