下面的代码可以正常运行:scorer = make_scorer(roc_auc_score)
但给出"ValueError: bad input shape":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)
我如何解决这个错误,使分数是基于概率估计?
如果你正在使用一个默认的评分指标,你不需要传递一个可调用的cross_val_score
,你可以,你可以只是调用它与你正在使用的指标的名称:
score = cross_val_score(clf, features, labels, cv=cv, scoring='roc_auc_score')