相关疑难解决方法(0)

如何在 Scikit-Learn (sklearn) 中使用带有多类标签的 `GridSearchCV` 中的 `log_loss`?

我正在尝试使用log_loss参数中的scoring参数GridSearchCV来调整这个多类(6 类)分类器。我不明白如何给它一个label参数。即使我给了它sklearn.metrics.log_loss,它也会在交叉验证中的每次迭代中改变,所以我不明白如何给它labels参数?

我正在使用Python v3.6Scikit-Learn v0.18.1

如何使用GridSearchCVlog_loss多级车型调整?

我的班级代表:

1    31
2    18
3    28
4    19
5    17
6    22
Name: encoding, dtype: int64
Run Code Online (Sandbox Code Playgroud)

我的代码:

param_test = {"criterion": ["friedman_mse", "mse", "mae"]}
gsearch_gbc = GridSearchCV(estimator = GradientBoostingClassifier(n_estimators=10), 
                        param_grid = param_test, scoring="log_loss", n_jobs=1, iid=False, cv=cv_indices)
gsearch_gbc.fit(df_attr, Se_targets)
Run Code Online (Sandbox Code Playgroud)

这是错误的结尾,完整的在这里https://pastebin.com/1CshpEBN

ValueError: y_true contains only one label (1). Please provide the true labels explicitly through …
Run Code Online (Sandbox Code Playgroud)

python optimization machine-learning scikit-learn grid-search

5
推荐指数
1
解决办法
4628
查看次数