-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FIX avoid race condition in RFECV #23560
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
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.
Thank you for the PR!
@@ -721,7 +721,7 @@ def fit(self, X, y, groups=None): | |||
func = delayed(_rfe_single_fit) | |||
|
|||
scores = parallel( | |||
func(rfe, self.estimator, X, y, train, test, scorer) | |||
func(rfe, clone(self.estimator), X, y, train, test, scorer) |
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.
Can we construct a non-regression test for this?
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.
Hi @thomasjpfan, I tried to reproduce the error in the original issue but wasn't able to do so :(. Could you help take a look if you got time, thank you!
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 am not sure if this is where the original error comes from. func = _rfe_single_fit
does not actually mutate estimator
:
def _rfe_single_fit(rfe, estimator, X, y, train, test, scorer): |
_rfe_single_fit
only uses estimator
for _safe_split
and the lambda function has it's own locally scoped `estimator.
scikit-learn/sklearn/feature_selection/_rfe.py
Lines 40 to 42 in 2f787f4
lambda estimator, features: _score( | |
estimator, X_test[:, features], y_test, scorer | |
), |
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.
Shall I close this PR for now ? Since it seems not related to the original issue
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.
Yea, I am okay with closing.
Reference Issues/PRs
Fixes #23533.
What does this implement/fix? Explain your changes.
Clones estimator before passing into parallel scoring jobs in
RFECV
.