-
-
Notifications
You must be signed in to change notification settings - Fork 25.7k
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
[MRG] Pass sample_weight when predicting on stacked folds #16539
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a |Fix|
entry to the change log at doc/whats_new/v0.23.rst
. Like the other entries there, please reference this pull request with :pr:
and credit yourself (and other contributors if applicable) with :user:
Please add a versionchanged note in the docstring of sample_weight
But tests are failing. Should have checked that first |
@jnothman : Thank you for the prompt review. I've added the requested doc changes and fixed the failing specs. Please let me know if you'd like more details in the versionchange/release notes or if you'd like to see more tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Only a couple of comments
…kingRegressor instead of _BaseStacking
@glemaitre Thank you for the comments. I updated the release notes to reference I also created a follow-on issue (#16595) regarding the naming of Please take another look at these changes and let me know if there is anything else you'd like me to include. |
sklearn/utils/_mocking.py
Outdated
@@ -96,6 +96,7 @@ def fit(self, X, y, **fit_params): | |||
assert self.check_X(X) | |||
if self.check_y is not None: | |||
assert self.check_y(y) | |||
self._check_n_features(X, reset=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to add this call so that n_features_in_
is set correctly in CheckingClassifier
.
The property is read during the fit method of BaseStacking: d205638#diff-c8f397939f2393da5b2eef4285761da1R143. We use CheckingClassifier
in the unit tests for the stacking estimators: https://github.com/scikit-learn/scikit-learn/pull/16539/files#diff-3979301645c7cbae79edc4085d997029R443
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR @wderose
LGTM!
Reference Issues/PRs
Fixes #16537.
What does this implement/fix? Explain your changes.
This PR passes
sample_weight
viafit_params
when we callcross_val_predict
in_BaseStacking
, as per the comment here.scikit-learn/sklearn/ensemble/_stacking.py
Lines 169 to 175 in 136ef79
Any other comments?
cc: @caioaao @glemaitre