K折交叉验证时使用:

KFold(n_split, shuffle, random_state)

  参数:n_split:要划分的折数

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

     random_state:随机状态

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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-07
  • 2021-09-07
  • 2021-05-18
  • 2021-10-26
  • 2021-05-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-30
  • 2021-11-09
  • 2021-07-16
相关资源
相似解决方案