Thanks to visit codestin.com
Credit goes to github.com

Skip to content

StratifiedKFold does not raise error when number of samples for all the classes is less than n_folds #6177

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
raghavrv opened this issue Jan 17, 2016 · 4 comments
Labels
Easy Well-defined and straightforward way to resolve

Comments

@raghavrv
Copy link
Member

We should raise an error instead of a warning (As pointed out by @MechCoder here)

import numpy as np
from sklearn.cross_validation import StratifiedKFold as OldSKF
from sklearn.model_selection import StratifiedKFold

X = np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]])
y = np.array([3, 3, -1, -1, 2, 2])

for tr, te in OldSKF(y, n_folds=3):
    print tr, te
[1 3 5] [0 2 4]
[0 2 4] [1 3 5]
[0 1 2 3 4 5] []
for tr, te in StratifiedKFold(n_folds=6).split(X, y):
    print tr, te
[1 3 5] [0 2 4]
[0 2 4] [1 3 5]
[0 1 2 3 4 5] []
[0 1 2 3 4 5] []
[0 1 2 3 4 5] []
[0 1 2 3 4 5] []

To be tagged "Easy", "Need Contributor"

cc: @MechCoder @amueller @jnothman

@raghavrv raghavrv changed the title StratifiedKFold does not raise error when the n_labels for all classes is less than n_folds StratifiedKFold does not raise error when the n_labels for individual classes is less than n_folds Jan 17, 2016
@devashishd12
Copy link
Contributor

@rvraghav93 I'll take this up

@MechCoder
Copy link
Member

It should be when "all the n_labels for individual classes is less than n_folds"

@raghavrv
Copy link
Member Author

@dsquareindia you are on fire! Please go ahead! Ping myself and @MechCoder when done. Thx

@MechCoder MechCoder changed the title StratifiedKFold does not raise error when the n_labels for individual classes is less than n_folds StratifiedKFold does not raise error when all the n_labels for individual classes is less than n_folds Jan 17, 2016
@devashishd12
Copy link
Contributor

Hahahaha sure!

@TomDLT TomDLT added Easy Well-defined and straightforward way to resolve Need Contributor and removed Need Contributor labels Jan 18, 2016
@raghavrv raghavrv changed the title StratifiedKFold does not raise error when all the n_labels for individual classes is less than n_folds StratifiedKFold does not raise error when number of samples for all the classes is less than n_folds Jan 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy Well-defined and straightforward way to resolve
Projects
None yet
Development

No branches or pull requests

4 participants