【发布时间】:2018-03-16 14:26:12
【问题描述】:
我正在为二进制分类问题构建一个随机森林分类器。我的标签都是数字的。
print labels.unique()
[1 0]
print type(labels)
<class 'pandas.core.series.Series'>
print labels.shape
(3000,)
但是当我用 Gridsearchcv 拟合模型时
pipeline = Pipeline(steps=[('scaler', scaler), ('algorithm', algo)])
cv = StratifiedShuffleSplit(labels, 5, test_size=0.25, random_state=42)
gs = GridSearchCV(pipeline, param_grid, cv=cv, scoring='f1')
gs.fit(features, labels)
我收到了这个错误
ValueError: Unknown label type: 'unknown'
但是当我使用
gs.fit(features, labels.astype(int))
一切正常。谁能告诉我标签的问题出在哪里?
【问题讨论】:
标签: python scikit-learn random-forest grid-search