问题描述
是否有任何内置方法可以使scikit-learn执行随机分层k折交叉验证?这是最常见的CV方法之一,但令我惊讶的是我找不到内置的方法来实现此目的.
Is there any built-in way to get scikit-learn to perform shuffled stratified k-fold cross-validation? This is one of the most common CV methods, and I am surprised I couldn't find a built-in method to do this.
我看到cross_validation.KFold()
有一个改组标志,但没有分层.不幸的是cross_validation.StratifiedKFold()
没有这样的选择,cross_validation.StratifiedShuffleSplit()
不会产生不相交的折叠.
I saw that cross_validation.KFold()
has a shuffling flag, but it is not stratified. Unfortunately cross_validation.StratifiedKFold()
does not have such an option, and cross_validation.StratifiedShuffleSplit()
does not produce disjoint folds.
我错过了什么吗?这是计划好的吗?
Am I missing something? Is this planned?
(显然我可以自己实现)
(obviously I can implement this by myself)
推荐答案
在当前版本0.15中引入了cross_validation.StratifiedKFold
的改组标志:
The shuffling flag for cross_validation.StratifiedKFold
has been introduced in the current version 0.15:
http://scikit-learn.org/0.15/modules/generation/sklearn.cross_validation.StratifiedKFold.html
这可以在变更日志中找到:
This can be found in the Changelog:
http://scikit-learn.org/stable/whats_new.html#新功能
这篇关于scikit-learn中的随机分层k折交叉验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!