1. 描述
KFold divides all the samples in k groups of samples, called folds (if k = n, this is equivalent to the Leave One Out strategy), of equal sizes (if possible). The prediction function is learned using k - 1 folds, and the fold left out is used for test.
2. 语法
sklearn.model_selection.KFold(n_splits=3, shuffle=False, random_state=None)
3. 参数:
1. n_splits:
int, default=3
Number of folds. Must be at least 2.
将训练/测试数据集划分n_splits个互斥子集,每次用n_splits-1个子集的并集作为训练集,余下的子集作为测试集
2. shuffle:
boolean, optional
Whether to shuffle the data before splitting into batches.
shuffle= False:不洗牌,每次运行结果相同,相当于random_state=整数
shuffle=True:洗牌,每次运行结果不同
shuffle=True和random_state=整数: 每次运行结果相同
3. random_state:
int, RandomState instance or None, optional, def