R 包 pROC 总是报告 AUC > 0.5

R package pROC always reports AUC > 0.5

两者都

pROC::auc(0:1, 1:0)
pROC::auc(0:1, 0:1)

AUC 为 1..

随着更多的实验,它似乎总是returns max(AUC, 1 - AUC)。 有没有办法改变这个? 我找不到 GitHub 报告此问题的回购协议。

试试 ModelMetrics 中的 auc 函数:

ModelMetrics::auc(0:1, 1:0)
ModelMetrics::auc(0:1, 0:1)

输出:

[1] 0
[1] 1

pROC::roc 中有一个参数 direction,默认设置为 auto。 来自 roc 的文档:

direction - in which direction to make the comparison? “auto” (default): automatically define in which group the median is higher and take the direction accordingly. “>”: if the predictor values for the control group are higher than the values of the case group (controls > t >= cases). “<”: if the predictor values for the control group are lower or equal than the values of the case group (controls < t <= cases).

pROC::auc(0:1, 1:0, direction = "<")
pROC::auc(0:1, 0:1,  direction = "<")

Calimo 的评论中给出了对这种基本原理的解释:没有理由假设较高的预测值在所有情况下都更积极。如模型指示负概率 class

更多内容可见