【发布时间】:2018-02-08 16:44:57
【问题描述】:
从标题我想知道有什么区别
StratifiedKFold 带参数 shuffle = True
StratifiedKFold(n_splits=10, shuffle=True, random_state=0)
和
StratifiedShuffleSplit(n_splits=10, test_size=’default’, train_size=None, random_state=0)
以及使用 StratifiedShuffleSplit 的优势是什么
【问题讨论】:
-
一个是k-fold迭代器,将数据拆分k次,其他只拆分一次
-
mmm 在 StratifiedShuffleSplit 中,您可以设置拆分次数...从 sklearn 网页: StratifiedShuffleSplit :此交叉验证对象是 StratifiedKFold 和 ShuffleSplit 的合并,它返回分层随机折叠。通过保留每个类的样本百分比来进行折叠。
-
啊,是的,我的错。但它仍然写在您链接的 StratifiedShuffleSplit 文档中,“这个交叉验证对象是 StratifiedKFold 和 ShuffleSplit 的合并,它返回分层随机折叠。折叠是通过保留每个类的样本百分比来实现的。”
-
差异在于折叠之间(数据在折叠中不重叠)。而在 StratifiedShuffleSplit 中,它可以并且将会重叠。请参阅文档页面上给出的示例以更好地理解它。具体测试数据。在 StratifiedKFold 中,每次折叠总是不同的。而在 StratifiedShuffleSplit 中,它可以是重复的。
-
听起来像
StratifiedKFold没有替换的样本,而StratifiedShiffleSplit随机播放。因此,StratifiedShiffleSplit的一个优势是您可以随意采样多次。当然,单个样本会有重叠——因此样本上的任何拟合模型都会相互关联——但您可以拟合更多模型,并且每个模型包含更多数据。
标签: python scikit-learn cross-validation