2017-05-26 80 views
0

在python我进口StratifiedKFold在Python给错误

>>> from sklearn.model_selection import StratifiedKFold 

>>> cv = StratifiedKFold(y, n_folds=5) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
TypeError: __init__() got an unexpected keyword argument 'n_folds' 

>>> print('The sklearn version is {}.'.format(sklearn.__version__)) 
The sklearn version is 0.18.1. 

我有sklearn 0.18.1。任何想法,为什么我得到这个错误?

+1

['sklearn.model_selection.StratifiedKFold'](http://scikit-learn.org/stable/modules/生成/ sklearn.model_selection.StratifiedKFold.html#sklearn-model-selection-stratifiedkfold) –

回答

0

为褶皱的数目的参数是n_splits,不n_folds

参见: http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.StratifiedKFold.html

+0

现在我试着cv = StratifiedKFold(n_split = 5),但对于我,(列车,测试)枚举(cv):给我错误TypeError: 'StratifiedKFold'对象不可迭代 – ajd

+0

我使用的代码来自https://github.com/dmlc/xgboost/blob/master/demo/gpu_acceleration/bosch.py​​ – ajd

+0

请尝试在枚举(cv.split(X,y))中为我(列车,测试):' – lukess