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

Skip to content

kfold cross validation assertion check #20

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
satra opened this issue Nov 23, 2010 · 2 comments
Closed

kfold cross validation assertion check #20

satra opened this issue Nov 23, 2010 · 2 comments

Comments

@satra
Copy link
Member

satra commented Nov 23, 2010

https://github.com/scikit-learn/scikit-learn/blob/master/scikits/learn/cross_val.py#L177

shouldn't this allow k=n? isn't that the definition for leave one out?

@satra
Copy link
Member Author

satra commented Nov 23, 2010

diff --git a/scikits/learn/cross_val.py b/scikits/learn/cross_val.py
index ba650f3..baa4fbb 100644
--- a/scikits/learn/cross_val.py
+++ b/scikits/learn/cross_val.py
@@ -174,7 +174,7 @@ class KFold(object):
     All the folds have size trunc(n/k), the last one has the complementary
     """
     assert k>0, ('cannot have k below 1')
-    assert k<n, ('cannot have k=%d greater than the number '
+    assert k<=n, ('cannot have k=%d greater than the number '
                         'of samples: %d'% (k, n))
     self.n = n
     self.k = k
@@ -253,7 +253,7 @@ class StratifiedKFold(object):
     y = np.asanyarray(y)
     n = y.shape[0]
     assert k>0, ValueError('cannot have k below 1')
-    assert k<n, ValueError('cannot have k=%d greater than the number '
+    assert k<=n, ValueError('cannot have k=%d greater than the number '
                            'of samples %d' % (k, n))
     _, y_sorted = unique(y, return_inverse=True)
     assert k <= np.min(np.bincount(y_sorted))

@GaelVaroquaux
Copy link
Member

This seemed to have been fixed (by Satra). I am closing.

This issue was closed.
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

No branches or pull requests

2 participants