-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[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
[MRG+1] check that splitters handle 2d y and give reasonable errors on multilabel y #9744
Conversation
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. 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(), |
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.
should this be a global or generated by a global function?
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 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.
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.
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))) |
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.
it's worth testing that it differs from KFold(3) to be sure that the assertion is meaningful
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.
assertion is copied from above. Should I add a check there, too?
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 suppose so
LGTM |
LGTM, merging, thanks a lot! |
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 |
Sorry, my mistake. This is fine. |
Fixes #9742.