当我尝试:
scores = cross_validation.cross_val_score(clf, features, target, cv=percent
, scoring =
metrics.make_scorer(metrics.precision_recall_fscore_support) )
print(scores)
我收到一个错误:
文件"D: Anaconda3 lib 网站 sklearn cross_validation.py",第1537行,在_score% (str(score), type(score))) ValueError: score必须返回一个数字,get (array([0.375, 0.91290323]), array([0.25,[0.94966443]), array([0.3, 0.93092105]), array([36,298], dtype=int64)) (
)代替。
任何想法?
我怀疑你的评分函数precision_recall_fscore_support
返回四个数字数组(precision, recall, fbeta_score和support),但scoring
要求可调用对象只返回一个数字。
尝试只使用fbeta_score
:
scores = cross_validation.cross_val_score(
clf, features, target, cv=percent,
scoring=metrics.make_scorer(
metrics.fbeta_score))