使用pROC意外的AUC ROC结果

时间:2016-09-05 04:51:54

标签: r

为什么pROC在以下示例中给出0.833,而ROCR给出0.75(这是我期望的)?

library(data.table)
library(pROC)
library(ROCR)

# Data
dt <- data.table(Pred=c(.5, .5, .5, 1), Outcome=c(1,0,0,1))

# Evaluation metrics
roc(dt$Pred, dt$Outcome)$auc  # 0.833
performance(prediction(dt$Pred, dt$Outcome), measure="auc")@y.values[[1]]  # 0.75

1 个答案:

答案 0 :(得分:0)

roc函数中,你必须像这样切换参数:

> roc( dt$Outcome,dt$Pred)

Call:
roc.default(response = dt$Outcome, predictor = dt$Pred)

Data: dt$Pred in 2 controls (dt$Outcome 0) < 2 cases (dt$Outcome 1).
Area under the curve: 0.75

或指定responsepredictor

的参数
 > roc(predictor=dt$Pred, response=dt$Outcome)

Call:
roc.default(response = dt$Outcome, predictor = dt$Pred)

Data: dt$Pred in 2 controls (dt$Outcome 0) < 2 cases (dt$Outcome 1).
Area under the curve: 0.75