-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] add groups support to RFECV #9656
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
Needs a test. |
X = iris.data | ||
y = (iris.target > 0).astype(int) | ||
|
||
# test basic cv |
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.
Why is this needed? Isn't it tested elsewhere?
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.
otherwise LGTM |
@@ -1250,3 +1254,30 @@ def test_cross_val_predict_sparse_prediction(): | |||
preds_sparse = cval.cross_val_predict(classif, X_sparse, y_sparse, cv=10) | |||
preds_sparse = preds_sparse.toarray() | |||
assert_array_almost_equal(preds_sparse, preds) | |||
|
|||
|
|||
def test_rfe_cv(): |
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.
Silly me, this shouldn't be in test_cross_validation. It should be in feature_selection/tests/test_rfe.py
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.
couple of small changes
cv=GroupKFold(n_splits=2) | ||
) | ||
est_groups.fit(X, y, groups=groups) | ||
assert(est_groups.n_features_ > 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.
You don't need the paranthesis
|
||
|
||
def test_rfe_cv_groups(): | ||
# test cv with groups |
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.
you can remove the comment since this is already implied by the name of the function
y = (iris.target > 0).astype(int) | ||
|
||
est_groups = RFECV( | ||
estimator=RandomForestClassifier(), |
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.
could you set the random_state of the estimator that take one.
Good job @adamgreenhall, thanks ! |
Reference Issue
related to #8127
What does this implement/fix? Explain your changes.
Adding support for cv groups (eg
LeaveOneGroupOut
) toRFECV
.