【发布时间】:2020-05-19 06:54:46
【问题描述】:
此代码适用于具有 2 个类但不适用于多类的数据集
scoring = {'accuracy' : make_scorer(accuracy_score),
'precision' : make_scorer(precision_score),
'recall' : make_scorer(recall_score),
'f1_score' : make_scorer(f1_score)}
scores = cross_val_score(gnb,x,y, cv=5, scoring=scoring)
print(scores)
错误显示
ValueError: For evaluating multiple scores, use sklearn.model_selection.cross_validate instead. {'accuracy': make_scorer(accuracy_score), 'precision': make_scorer(precision_score, average=None), 'recall': make_scorer(recall_score), 'f1_score': make_scorer(f1_score)} was passed
当我检查代码并像这样更改它时
scores = cross_val_score(gnb,x,y, cv=5, scoring='precision')
错误显示
ValueError: Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted'].
当我在make_scorer 中设置average 时它不起作用
【问题讨论】:
标签: python scikit-learn cross-validation