假设我定义了以下评分函数:
def multi_label_macro_auc(y_gt, y_pred):
n_labels = y_pred.shape[1]
auc_scores = [None] * n_labels
# Convert the multi-class ground truth to a binary ground truth
# by iterating through the labels
for label in xrange(n_labels):
auc_scores[label] = roc_auc_score((y_gt == label)*1, y_pred[:,label])
return np.mean(auc_scores)
ml_macro_auc_s = make_scorer(multi_label_macro_auc, greater_is_better=True,
needs_threshold=False, needs_proba=True)
我在我的数据中学会了DummyClassifier
:
如果我尝试对照评分函数测试这个虚拟分类器:
ml_macro_auc_s(dummy_clf, X, y)
scikit learn抱怨:
"ValueError: AUC is defined for binary classification only"
我尝试将probability=True
传递给DummyClassifier
,但它似乎接受了{a1}参数:
dummy_clf = DummyClassifier(strategy='stratified'',random_state=0, probability=True)
如何将需要软输出的我自己的记分器应用到DummyClassifier
?在
y
是一个1D数组,其值在[0,1,2]
范围内X
是一个特性数组,其行数与y和125
列相同
目前没有回答
相关问题 更多 >
编程相关推荐