Bootstrap

ValueError: n_splits=4 cannot be greater than the number of members in each class.



  相信刚开始使用sklearn中cross_val_score()函数进行K折交叉验证的小伙伴们都可能会遇到以下错误:

ValueError: n_splits=4 cannot be greater than the number of members in each class



  出现这个错误的原因是我们设置的折数大于每个类的样本数。比如说在所有的类中,数量最多的类的样本个数是7,这时如果我们把 n _ s p l i t s n\_splits n_splits设置为8,就会报这个错误。

;