Skip to content

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

Closed

Conversation

MaxwellLZH
Copy link
Contributor

Reference Issues/PRs

Fixes #23533.

What does this implement/fix? Explain your changes.

Clones estimator before passing into parallel scoring jobs in RFECV.

Copy link
Member

@thomasjpfan thomasjpfan left a 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)
Copy link
Member

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?

Copy link
Contributor Author

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!

Copy link
Member

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.

lambda estimator, features: _score(
estimator, X_test[:, features], y_test, scorer
),

Copy link
Contributor Author

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

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFECV race condition on estimator
2 participants