auc: Calculate AUC

Description Usage Arguments Details Value Author(s) References Examples

Description

Calculate AUC with or without missing

Usage

1
auc(pred, lable, draw = F, option = "all")

Arguments

pred

prediction results (real value)

lable

target value (binary)

draw

If TRUE, then draw a ROC curve

option

Missing Value handling

Details

This function is a wrapper of ROCR

Value

return value is area under curve.

Author(s)

Yifan Yang

References

ROCR

Examples

 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)
  }

BioStaCs/BSCgas documentation built on May 6, 2019, 12:06 a.m.