【发布时间】:2021-11-02 15:28:39
【问题描述】:
TypeError: unsupported operand type(s) for /: 'dict' and 'int'
`
**Here is my code**
x = df[header]
clf=GaussianNB()
scoring = {
'accuracy' : make_scorer(accuracy_score),
'precision' : make_scorer(precision_score,average = 'micro'),
'recall' : make_scorer(recall_score,average = 'micro'),
'f1_score' : make_scorer(f1_score,average = 'micro')
}
scores = cross_validate(clf, x, y, scoring=scoring, cv=5)
print(np.mean(scores))
当我运行这段代码时,它给了我这个错误,当我尝试像这样打印print(scores['precision']) 时,它给出了一个关键的精度错误。请建议我如何改进我的代码并通过对多类使用交叉验证来计算多个精度。
【问题讨论】:
标签: python machine-learning cross-validation multiclass-classification precision-recall