Skip to content

[MRG+1] check that splitters handle 2d y and give reasonable errors on multilabel y #9744

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 3 commits into from
Oct 9, 2017

Conversation

amueller
Copy link
Member

Fixes #9742.

Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

otherwise lgtm. will include in bugfix release, I think..?

y_2d = y.reshape(-1, 1)
y_multilabel = rng.randint(0, 2, size=(n_samples, 3))
groups = rng.randint(0, 3, size=(n_samples,))
splitters = [LeaveOneOut(), LeavePOut(p=2), KFold(), StratifiedKFold(),
Copy link
Member

Choose a reason for hiding this comment

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

should this be a global or generated by a global function?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was considering it. A global variable seems consistent with other lists of classes, but I didn't do that given that it's only used once so far.

Copy link
Member

Choose a reason for hiding this comment

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

pytest.mark.parametrize?

y_multiclass_2d = y_multiclass.reshape(-1, 1)
cv = check_cv(3, y_multiclass_2d, classifier=True)
np.testing.assert_equal(list(StratifiedKFold(3).split(X, y_multiclass_2d)),
list(cv.split(X, y_multiclass_2d)))
Copy link
Member

Choose a reason for hiding this comment

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

it's worth testing that it differs from KFold(3) to be sure that the assertion is meaningful

Copy link
Member Author

@amueller amueller Sep 20, 2017

Choose a reason for hiding this comment

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

assertion is copied from above. Should I add a check there, too?

Copy link
Member

Choose a reason for hiding this comment

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

I suppose so

@jnothman jnothman added this to the 0.19.1 milestone Sep 18, 2017
@jnothman
Copy link
Member

LGTM

@jnothman jnothman changed the title check that splitters handle 2d y and give reasonable errors on multilabel y [MRG+1] check that splitters handle 2d y and give reasonable errors on multilabel y Sep 26, 2017
@lesteve
Copy link
Member

lesteve commented Oct 9, 2017

LGTM, merging, thanks a lot!

@lesteve lesteve merged commit 94fa697 into scikit-learn:master Oct 9, 2017
@jnothman
Copy link
Member

jnothman commented Oct 9, 2017

Now that we've merged this, I'm not sure why we should be stopping users have multilabel y in splitters that do not depend on y's data, such as KFold. What are we doing again?

@jnothman
Copy link
Member

Sorry, my mistake. This is fine.

jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Oct 16, 2017
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
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.

3 participants