I am trying to run the following code:
from sklearn.model_selection import StratifiedKFold
X = ["hey", "join now", "hello", "join today", "join us now", "not today", "join this trial", " hey hey", " no", "hola", "bye", "join today", "no","join join"]
y = ["n", "r", "n", "r", "r", "n", "n", "n", "n", "r", "n", "n", "n", "r"]
skf = StratifiedKFold(n_splits=10)
for train, test in skf.split(X,y):
print("%s %s" % (train,test))
But I get the following error:
ValueError: n_splits=10 cannot be greater than the number of members in each class.
I have looked here scikit-learn error: The least populated class in y has only 1 member but I'm still not really sure what is wrong with my code.
My lists both have lengths of 14 print(len(X))
print(len(y))
.
Part of my confusion is that I am not sure what a members
is defined as and what a class
is in this context.
Questions: How do I fix the error? What is a member? What is a class? (in this context)
"y"
are included). I wanted to replicate the error with a shorter list ofX
andy
. The idea is to perform 10 fold cross validation on the dataset. That is why I wanted to usen_split = 10
. And I use stratification because there are 2000n
and 163y
. I thought keeping these ratio's consistent would be desirable – Conklin