-
-
Notifications
You must be signed in to change notification settings - Fork 26k
[MRG+1] RFE can raise NotFittedError #9283
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
need to squash commits |
no need, GitHub will squash when merging |
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.
RFE doesnt raise NotFittedError, suspect other meta feature selectors have same issue.
I checked, the other classes inheriting SelectorMixin
all have already a specific check_is_fitted
call.
LGTM
There should really be a non-regression test. |
sklearn/feature_selection/rfe.py
Outdated
@@ -251,6 +252,7 @@ def score(self, X, y): | |||
return self.estimator_.score(self.transform(X), y) | |||
|
|||
def _get_support_mask(self): | |||
check_is_fitted(self, 'support_') # will raise NotFittedError if not fitted |
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 line is too long (>79 characters), you may remove the comment
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!
Though now I wonder if it would be nice for check_is_fitted
to return the value of that attribute... Hmm. Not required in this PR.
@TomDLT, this has changed a lot since you gave it +1. Could you please check again?
sklearn/tests/test_metaestimators.py
Outdated
@@ -102,6 +104,8 @@ def score(self, X, *args, **kwargs): | |||
self._check_fit() | |||
return 1.0 | |||
|
|||
|
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.
These two blank lines should not have been added
is there an exhaustive list of estimators somewhere, so I can find more that don't raise In terms of a longer-term solution, maybe |
This kind of thing is tested by way of
|
LGTM 👍 : merging now, more improvements can come later. |
* RFE can raise NotFittedError * boom boom * dont change tests * tests pass * remove two extra lines
* RFE can raise NotFittedError * boom boom * dont change tests * tests pass * remove two extra lines
* RFE can raise NotFittedError * boom boom * dont change tests * tests pass * remove two extra lines
* RFE can raise NotFittedError * boom boom * dont change tests * tests pass * remove two extra lines
* RFE can raise NotFittedError * boom boom * dont change tests * tests pass * remove two extra lines
* RFE can raise NotFittedError * boom boom * dont change tests * tests pass * remove two extra lines
* RFE can raise NotFittedError * boom boom * dont change tests * tests pass * remove two extra lines
* RFE can raise NotFittedError * boom boom * dont change tests * tests pass * remove two extra lines
Reference Issue
Fixes Issue #9276
What does this implement/fix? Explain your changes.
Any other comments?