Description Usage Arguments Details Value Author(s) References Examples
Calculate AUC with or without missing
1 | auc(pred, lable, draw = F, option = "all")
|
pred |
prediction results (real value) |
lable |
target value (binary) |
draw |
If TRUE, then draw a ROC curve |
option |
Missing Value handling |
This function is a wrapper of ROCR
return value is area under curve.
Yifan Yang
ROCR
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (pred, lable, draw = F, option = "all")
{
if (option == "all") {
pred.roc <- prediction(pred, lable)
perf <- performance(pred.roc, "tpr", "fpr")
if (draw)
plot(perf, col = 2, main = "GLM")
perf.auc <- performance(pred.roc, "auc")
perf.auc.areas <- slot(perf.auc, "y.values")
curve.area <- mean(unlist(perf.auc.areas))
}
else {
nomissing <- !is.na(lable)
pred <- pred[nomissing]
lable <- lable[nomissing]
pred.roc <- prediction(pred, lable)
perf <- performance(pred.roc, "tpr", "fpr")
if (draw)
plot(perf, col = 2, main = "GLM")
perf.auc <- performance(pred.roc, "auc")
perf.auc.areas <- slot(perf.auc, "y.values")
curve.area <- mean(unlist(perf.auc.areas))
}
return(curve.area)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.