ValueError: 'balanced_accuracy' 不是 scikit-learn 中的有效评分值 [英] ValueError: 'balanced_accuracy' is not a valid scoring value in scikit-learn

查看:26
本文介绍了ValueError: 'balanced_accuracy' 不是 scikit-learn 中的有效评分值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将其他评分指标传递给 GridSearchCV,例如用于二元分类的 balanced_accuracy(而不是默认的 accuracy)

I tried to pass to GridSearchCV other scoring metrics like balanced_accuracy for Binary Classification (instead of the default accuracy)

  scoring = ['balanced_accuracy','recall','roc_auc','f1','precision']
  validator = GridSearchCV(estimator=clf, param_grid=param_grid, scoring=scoring, refit=refit_scorer, cv=cv)

并得到这个错误

ValueError: 'balanced_accuracy' 不是一个有效的评分值.有效的选项是['accuracy','adjusted_mutual_info_score','adjusted_rand_score','average_precision','completeness_score','explained_variance','f1','f1_macro','f1_micro','f1_samples','f1_weighted','fowlscore_allowkes'homogeneity_score','mutual_info_score','neg_log_loss','neg_mean_absolute_error','neg_mean_squared_error','neg_mean_squared_log_error','neg_median_absolute_error','normalized_mutual_info_score,'precision',precision_sample'precision'precision_sample'precision_microprecision','r2','recall','recall_macro','recall_micro','recall_samples','recall_weighted','roc_auc','v_measure_score']

ValueError: 'balanced_accuracy' is not a valid scoring value. Valid options are ['accuracy','adjusted_mutual_info_score','adjusted_rand_score','average_precision','completeness_score','explained_variance','f1','f1_macro','f1_micro','f1_samples','f1_weighted','fowlkes_mallows_score','homogeneity_score','mutual_info_score','neg_log_loss','neg_mean_absolute_error','neg_mean_squared_error','neg_mean_squared_log_error','neg_median_absolute_error','normalized_mutual_info_score','precision','precision_macro','precision_micro','precision_samples','precision_weighted','r2','recall','recall_macro','recall_micro','recall_samples','recall_weighted','roc_auc','v_measure_score']

这很奇怪,因为 'balanced_accuracy' 应该是有效没有定义 balanced_accuracy 那么代码工作正常

This is strange because 'balanced_accuracy' should be valid Without defining balanced_accuracy then the code works fine

    scoring = ['recall','roc_auc','f1','precision']

此外,上述错误中的评分指标似乎与 文档

Also the scoring metrics in the error above seems to be different from the ones in the document

有什么想法吗?非常感谢

Any ideas why? Thank you so much

scikit-learn 版本是 0.19.2

scikit-learn version is 0.19.2

推荐答案

如果您想使用 balanced_accuracy,请将您的 sklearn 更新到最新版本.正如您在 0.19 文档中所见balanced_accuracy 不是有效的评分指标.它是 在 0.20 中添加.

Update your sklearn to the latest version if you want to use balanced_accuracy. As you can see from the 0.19 documentation balanced_accuracy is not a valid scoring metric. It was added in 0.20.

这篇关于ValueError: 'balanced_accuracy' 不是 scikit-learn 中的有效评分值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆