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, default=None
If int, random_state is the seed used by the random number generator;
If Rand

KFold是一种交叉验证方法,将数据集划分为k个互斥的子集,每次使用k-1个子集进行训练,剩余子集用于测试。参数包括n_splits(默认3)用于指定折数,shuffle(默认False)决定是否洗牌,以及random_state控制随机性。方法包括get_n_splits返回划分次数和split生成训练测试集的索引。实例展示了3折交叉验证的切分方式。
最低0.47元/天 解锁文章
2万+

被折叠的 条评论
为什么被折叠?



