Skip to content

removing extra tests, as they all raise the same error of min number of classes #15069

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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions sklearn/model_selection/tests/test_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,16 +633,17 @@ def test_stratified_shuffle_split_init():
assert_raises(ValueError, next,
StratifiedShuffleSplit(3, 0.2).split(X, y))

X = np.arange(9)
y = np.asarray([0, 0, 0, 1, 1, 1, 2, 2, 2])

# Check that error is raised if the test set size is smaller than n_classes
Copy link
Author

Choose a reason for hiding this comment

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

@jnothman the test written below wasn't testing what comment said.

Copy link
Author

Choose a reason for hiding this comment

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

of course I might be wrong in my assumption, I am not sure anymore!

Copy link
Member

Choose a reason for hiding this comment

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

To avoid confusion in the future, we can use

msg = "The test_size = 2 should be greater or equal to the number of classes = 3"
with pytest.raises(ValueError, match=msg):
    next(StratifiedShuffleSplit(3, 2).split(X, y))

so we can check for the error message explicitly.

Copy link
Author

Choose a reason for hiding this comment

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

will add these to the messages!

assert_raises(ValueError, next, StratifiedShuffleSplit(3, 2).split(X, y))

# Check that error is raised if the train set size is smaller than
# n_classes
assert_raises(ValueError, next,
StratifiedShuffleSplit(3, 3, 2).split(X, y))

X = np.arange(9)
y = np.asarray([0, 0, 0, 1, 1, 1, 2, 2, 2])

# Train size or test size too small
assert_raises(ValueError, next,
StratifiedShuffleSplit(train_size=2).split(X, y))
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy