sss = StratifiedShuffleSplit(labels,10,test_size=0.2, random_state=23)
for train_index, test_index in sss:
X_train, X_test = train.values[train_index], train.values[test_index]
y_train, y_test = labels[train_index], labels[test_index]
之前,我使用sklearn.cross_validation import StratifiedShuffleSplit。但是它没有用。然后我从sklearn.model_selection import StratifiedShuffleSplit
开始尝试,它抛出以下错误:
TypeError Traceback (most recent call last)
<ipython-input-37-340cc4ca20bc> in <module>()
----> 1 sss = StratifiedShuffleSplit(labels,10,test_size=0.2, random_state=23)
2
3 for train_index, test_index in sss:
4 X_train, X_test = train.values[train_index], train.values[test_index]
5 y_train, y_test = labels[train_index], labels[test_index]
TypeError: __init__() got multiple values for argument 'test_size'
如果恢复了test_size错误,则其余代码将起作用
答案 0 :(得分:0)
在该行中:
sss = StratifiedShuffleSplit(labels,10,test_size=0.2, random_state=23)
您正在为参数test_size
传递多个值(在这种情况下,您正在传递10
和0.2
)。
请阅读the documentation on StratifiedShuffleSplit以获得更多说明。也许将该行更改为:
sss = StratifiedShuffleSplit(10, test_size=0.2, random_state=23)