校准会提高 roc 分数吗?

Does calibration improve roc score?

我正在研究执行校准分类器的效果,我读到校准的目的是使分类器的预测更多 'reliable'。 考虑到这一点,我认为经过校准的分类器会有更高的分数 (roc_auc)

在 Python 中使用 sklearn y 测试这个假设时发现恰恰相反

能否解释一下:

校准会提高 roc 分数吗? (或任何指标)

如果不是真的。什么is/are执行校准advantage/es?

clf=SVC(probability=True).fit(X_train,y_train)
calibrated=CalibratedClassifierCV(clf,cv=5,method='sigmoid').fit(X_train,y_train)
probs=clf.predict_proba(X_test)[:,1]
cal_probs=calibrated.predict_proba(X_test)[:,1]

plt.figure(figsize=(12,7))
names=['non-calibrated SVM','calibrated SVM']
for i,p in enumerate([probs,cal_probs]):
    plt.subplot(1,2,i+1)
    fpr,tpr,threshold=roc_curve(y_test,p)
    plt.plot(fpr,tpr,label=nombre[i],marker='o')
    plt.title(names[i]+ '\n' + 'ROC: '+ str(round(roc_auc_score(y_test,p),4)))
    plt.plot([0,1],[0,1],color='red',linestyle='--')
    plt.grid()
    plt.tight_layout()
    plt.xlim([0,1])
    plt.ylim([0,1])

TLDR:校准不应影响 ROCAUC。

更长的答案:

ROCAUC 是排名的衡量标准 ("did we put these observations in the best possible order?")。但是,它并不能确保良好的概率。

Example: If I'm classifying how likely someone is to have cancer, I may always say a number between 95% and 99%, and still have perfect ROCAUC, as long as I've made my predictions in the right order (the 99%s had cancer, the 95%s did not).

Here we would say that this classifier (that says 95% when then are unlikely to have cancer) has good ability to rank, but is badly calibrated.

那我们能做什么呢?我们可以应用 monotonic 转换,在不改变等级能力的情况下修复它(因此不改变 ROCAUC)。

Example: in our cancer example we can say the predictions are under 97.5% they should be decreased by 90%, and when they are over 97.5% they would be kept. This really crass approach will not affect the ROC, but would send the "lowest" predictions to close to 0, improving our calibration, as measured by the Brier Score.

太好了,现在我们可以变聪明了!提高我们的 Brier 分数的 "best" 单调曲线是什么?好吧,我们可以 let Python deal with this by using scikit's calibration,它基本上为我们找到了那条曲线。同样,它将改进校准,但不会更改 ROCAUC,因为排名顺序保持不变。

太好了,所以 ROCAUC 没有移动。

然而...
在承认地球不绕太阳转后引用伽利略的话...... "E pur si muove" (然而它移动)

好的。现在事情变得很奇怪。为了进行单调变换,一些接近的观察值(例如 25% 和 25.5%)可能会 "squished" 在一起(例如 0.7% 和 0.700000001%)。这可能是四舍五入的,导致预测变得并列。然后,当我们计算 ROCAUC 时……它会移动。

但是,出于所有实际目的,您可以预期 "real" ROCAUC 不会受到校准的影响,并且它应该只会影响您测量概率的能力,如 Brier Score 所测量的