sklearn的K折交叉验证函数KFold使用

sklearn的K折交叉验证函数KFold使用,第1张

sklearn的K折交叉验证函数KFold使用

K折交叉验证时使用:

KFold(n_split, shuffle, random_state)

  参数:n_split:要划分的折数

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

     random_state:随机状态

 from sklearn.model_selection import KFold
kf = KFold(5, True, 10) X, Y = loda_data('./data.txt')
for train_index, test_index in kf.split(X):
print('训练集:{}'.format(train_index)
print('测试集:{}'.format(test_index)

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/586470.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存