k折交叉验证KFold()函数的使用

KFold(n_split, shuffle, random_state)

  参数:n_splits:要划分的折数

     shuffle: 每次都进行shuffle,测试集中折数的总和就是训练集的个数

     random_state:随机状态

 

from sklearn.model_selection import KFold

kf = KFold(n_splits=3,random_state=1)

for train, test in kf.split(titanic):

  titanic为X,即要使用的数据集

posted @ 2020-03-18 21:15  学无止境zjk  阅读(2289)  评论(0)    收藏  举报