8000 [MRG+1] add groups support to RFECV by adamgreenhall · Pull Request #9656 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
8000

[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

Merged
merged 9 commits into from
Nov 17, 2017

Conversation

adamgreenhall
Copy link
Contributor
@adamgreenhall adamgreenhall commented Aug 30, 2017

Reference Issue

related to #8127

What does this implement/fix? Explain your changes.

Adding support for cv groups (eg LeaveOneGroupOut) to RFECV.

@jnothman
Copy link
Member

Needs a test.

X = iris.data
y = (iris.target > 0).astype(int)

# test basic cv
Copy link
Member

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?

Copy link
Contributor Author
@adamgreenhall adamgreenhall Sep 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe here - but from looking at it, I'm not totally sure. @jnothman - do you know?

also, happy to move this to test_metaestimators.py if that's better.

@jnothman
Copy link
Member
jnothman commented Sep 1, 2017

otherwise LGTM

@jnothman jnothman changed the title add groups [MRG+1] add groups support to RFECV Sep 1, 2017
@@ -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():
Copy link
Member

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

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

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
Copy link
Member

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(),
Copy link
Member

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.

@TomDLT TomDLT merged commit 48b82a6 into scikit-learn:master Nov 17, 2017
@TomDLT
Copy link
Member
TomDLT commented Nov 17, 2017

Good job @adamgreenhall, thanks !

jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0