为什么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
答案 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
或指定response
和predictor
> 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