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
API Replacing grid_scores_ by cv_results_ in _rfe.py and test_rfe.py #20161
API Replacing grid_scores_ by cv_results_ in _rfe.py and test_rfe.py #20161
Conversation
Merging changes from the main repository
Merging changes from the main repository
Merging changes from the main repository
Rfe.py update
…ps://github.com/arka204/scikit-learn into Replacing-grid_scores_-by-cv_results-in-_rfe.py
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
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.
LGTM. Just a few minor remarks below (ignore the third that I just left for other reviewers).
sklearn/feature_selection/_rfe.py
Outdated
scores_rev = scores[:, ::-1] | ||
self.cv_results_ = {} | ||
self.cv_results_["mean_score"] = np.mean(scores_rev, axis=0) | ||
self.cv_results_["std_score"] = np.std(scores_rev, axis=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.
I am wondering if we should not use mean_test_score
/ std_test_score
/ split{i}_test_score
instead.
- this would be more consistent with
GridSearchCV
- this would be more future proof in case we want to add an option to also compute the training score in RFECV although this is probably a case of YAGNI.
Edit actuall ignore that remark. #16392 already uses the mean_score
notation...
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.
Being consistent with GridSearchCV
looks like a net win to me. I am okay with deprecating mean_score
in GraphicalLassoCV
and switch to using *_test_score
instead.
@ogrisel Do you think deprecating would be too much of a hassle?
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 fine with both approaches.
We probably need an entry to document the deprecation attribute in |
The black code style has been applied. |
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 still fine with this PR but I think you would get a faster second reviewer approval if you address this comment: https://github.com/scikit-learn/scikit-learn/pull/20161/files#r646027286
The handling of the deprecation cycle of the same attributes in GraphicalLassoCV
can be tackled in a separate PR.
I am +1 on changing the names of the keys as described in #20161 (comment) Would it be okay to make this change in this PR? |
@thomasjpfan |
sklearn/feature_selection/_rfe.py
Outdated
self.cv_results_["mean_score"] = np.mean(scores_rev, axis=0) | ||
self.cv_results_["std_score"] = np.std(scores_rev, axis=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.
I think that @thomasjpfan mentioned in its previous post was to change both entries using mean_test_score
and std_test_score
here.
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'm sorry, I was mistaken about that.
Would it be okay to just change the names?
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.
yes it should be enough
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 understand. Thank you so much.
…es_-by-cv_results-in-_rfe.py
LGTM. I pushed a tiny nitpick for the f-string styling. |
Thank you for all of you. |
…cikit-learn#20161) Co-authored-by: arka204 <kmichalik204@gmail.com> Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com> Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Reference Issues/PRs
Continues #16961
Partially fixes #11198
Based on #16392
What does this implement/fix? Explain your changes.
This PR replaces grid_scores_ by cv_results_ in _rfy.py and test_rfe.py.