赞
踩
class sklearn.model_selection.StratifiedKFold(n_splits=5, *, shuffle=False, random_state=None)
参数:
n_splits:int, default=5
表示把数据划分成几等分
shuffle:bool, default=False
在每次划分时,是否进行洗牌
random_stateint or RandomState instance, default=None
:随机种子数`>>> from sklearn.model_selection import StratifiedKFold
>>> X = np.ones(10)
>>> y = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1]
>>> skf = StratifiedKFold(n_splits=3)
>>> for train, test in skf.split(X, y):
... print("%s %s" % (train, test))
[2 3 6 7 8 9] [0 1 4 5]
[0 1 3 4 5 8 9] [2 6 7]
[0 1 2 4 5 6 7] [3 8 9]
参考:
sklearn中文文档:http://scikitlearn.com.cn/0.21.3/30/#31221-k
StratifiedKFold和KFold生成交叉验证数据集的区别:https://blog.csdn.net/MsSpark/article/details/84455402
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。