以下代码适用于:
scorer = make_scorer(roc_auc_score)
但是给出了#34; ValueError:错误的输入形状"搭配:
scorer = make_scorer(roc_auc_score, needs_proba = True)
代码是:
clf = GaussianNB()
cv = ShuffleSplit(features.shape[0], n_iter = 10, test_size = 0.2, random_state = 0)
scorer = make_scorer(roc_auc_score, needs_proba = True)
score = cross_val_score(clf, features, labels, cv=cv, scoring=scorer)
如何解决此错误,以便得分基于概率估算?
答案 0 :(得分:1)
如果您使用的是默认评分指标之一,则无需将可调用对象传递给cross_val_score
,您可以只使用您正在使用的指标名称来调用它:
score = cross_val_score(clf, features, labels, cv=cv, scoring='roc_auc_score')