scikit-learn之sklearn.model_selection.StratifiedFold

StratifiedFold是scikit-learn库中的一个分层K-Folds交叉验证工具,确保每个折中各类样本的比例与整体数据保持一致。它提供了split方法用于划分训练集和测试集,以及get_n_splits方法返回拆分次数。
摘要由CSDN通过智能技术生成

StratifiedFold

Stratified K-Folds cross-validator

Provides train/test indices to split data in train/test sets.

This cross-validation object is a variation of KFold that returns stratified folds. The folds are made by preserving the percentage of samples for each class.

class sklearn.model_selection.StratifiedKFold(n_splits=’warn’, shuffle=False, random_state=None)
Parameters:	
n_splits : int, default=3
Number of folds. Must be at least 2.

Changed in version 0.20: n_splits default value will change from 3 to 5 in v0.22.

shuffle : boolean, optional
Whether to shuffle each class’s samples before splitting into batches.

random_state : int, RandomState instance or None, optional, default=None
If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值