gpt4 book ai didi

python - Balanced_accuracy 不是 scikit-learn 中的有效评分值

转载 作者:行者123 更新时间:2023-12-02 13:08:27 24 4
gpt4 key购买 nike

与这篇文章 super 相似:ValueError: 'balanced_accuracy' is not a valid scoring value in scikit-learn

我正在使用:

scoring = ['precision_macro', 'recall_macro', 'balanced_accuracy_score']
clf = DecisionTreeClassifier(random_state=0)
scores = cross_validate(clf, X, y, scoring=scoring, cv=10, return_train_score=True)

我收到错误:

ValueError: 'balanced_accuracy_score' is not a valid scoring value. Use sorted(sklearn.metrics.SCORERS.keys()) to get valid options.

我做了推荐的解决方案并升级了 scikit (在环境中): enter image description here

当我检查可能的得分手时:

sklearn.metrics.SCORERS.keys()
dict_keys(['explained_variance', 'r2', 'max_error', 'neg_median_absolute_error', 'neg_mean_absolute_error', 'neg_mean_squared_error', 'neg_mean_squared_log_error', 'neg_root_mean_squared_error', 'neg_mean_poisson_deviance', 'neg_mean_gamma_deviance', 'accuracy', 'roc_auc', 'roc_auc_ovr', 'roc_auc_ovo', 'roc_auc_ovr_weighted', 'roc_auc_ovo_weighted', 'balanced_accuracy', 'average_precision', 'neg_log_loss', 'neg_brier_score', 'adjusted_rand_score', 'homogeneity_score', 'completeness_score', 'v_measure_score', 'mutual_info_score', 'adjusted_mutual_info_score', 'normalized_mutual_info_score', 'fowlkes_mallows_score', 'precision', 'precision_macro', 'precision_micro', 'precision_samples', 'precision_weighted', 'recall', 'recall_macro', 'recall_micro', 'recall_samples', 'recall_weighted', 'f1', 'f1_macro', 'f1_micro', 'f1_samples', 'f1_weighted', 'jaccard', 'jaccard_macro', 'jaccard_micro', 'jaccard_samples', 'jaccard_weighted'])

我还是找不到?问题出在哪里?

最佳答案

根据docs for valid scorers ,与balanced_accuracy_score scorer function对应的scoring参数的值是“balanced_accuracy”,如我的其他答案:

更改:

scoring = ['precision_macro', 'recall_macro', 'balanced_accuracy_score']

至:

scoring = ['precision_macro', 'recall_macro', 'balanced_accuracy']

它应该可以工作。

我确实发现文档在这方面有点缺乏,并且删除 _score 后缀的约定也不一致,因为所有聚类指标仍然具有 _score在他们的名字和他们的评分参数值中。

关于python - Balanced_accuracy 不是 scikit-learn 中的有效评分值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59377154/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com