【发布时间】:2019-07-05 11:35:36
【问题描述】:
我正在使用 SKLearn 版本 (0.20.2),如下:
from sklearn.model_selection import StratifiedKFold
grid = GridSearchCV(
pipeline, # pipeline from above
params, # parameters to tune via cross validation
refit=True, # fit using all available data at the end, on the best found param combination
scoring='accuracy', # what score are we optimizing?
cv=StratifiedKFold(label_train, n_splits=5), # what type of cross validation to use
)
但我不明白为什么我会收到这个错误:
TypeError Traceback (most recent call last)
<ipython-input-26-03a56044cb82> in <module>()
10 refit=True, # fit using all available data at the end, on the best found param combination
11 scoring='accuracy', # what score are we optimizing?
---> 12 cv=StratifiedKFold(label_train, n_splits=5), # what type of cross validation to use
13 )
TypeError: __init__() got multiple values for argument 'n_splits'
我已经尝试过n_fold,但出现了相同的错误结果。并且也厌倦了更新我的 scikit 版本和我的 conda。有什么办法解决这个问题吗?非常感谢!
【问题讨论】:
-
删除
label_train; first 参数被命名为n_splits。
标签: python scikit-learn