0

I'm trying to build validation curve that relying on max_depth but keep getting an error:

n_splits=10 cannot be greater than the number of members in each class.

I tried to put n_splits with different values, error doesnt change. I got data from .cvs file with numeric data

Here is code fragment that gets error:

from sklearn.tree import DecisionTreeClassifier
    model = DecisionTreeClassifier(random_state=123)
    cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=132)
    train_scores, valid_scores = validation_curve(model, X, y, param_name="max_depth", n_jobs=-1,
       param_range=np.arange(1, 20), cv=10, scoring="accuracy")

Im working in Jupiter Lite.

liewife
  • 51
  • 6
  • 1
    Per the error, how many samples do you have to for each class label? – G. Anderson Dec 12 '22 at 21:11
  • not sure that i understand what you are asking, im working with table with 18 colums and 442 row for each – liewife Dec 13 '22 at 15:27
  • The error is telling you that at least one of your targets, the classes you're trying to predict, has less than 10 samples/rows. Out of your 442 rows, check to see how many represent each target class – G. Anderson Dec 14 '22 at 16:37

0 Answers0