Learn R Programming

mltools (version 0.3.4)

auc_roc: Area Under the ROC Curve

Description

Calculates Area Under the ROC Curve

Usage

auc_roc(preds, actuals, returnDT = FALSE)

Arguments

preds

A vector of prediction values

actuals

A vector of actuals values (numeric or ordered factor)

returnDT

If TRUE, a data.table of (FalsePositiveRate, TruePositiveRate) pairs is returned, otherwise AUC ROC score is returned

Details

If returnDT=FALSE, returns Area Under the ROC Curve.If returnDT=TRUE, returns a data.table object with False Positive Rate and True Positive Rate for plotting the ROC curve.

References

https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve

Examples

Run this code
# NOT RUN {
library(data.table)
preds <- c(.1, .3, .3, .9)
actuals <- c(0, 0, 1, 1)
auc_roc(preds, actuals)
auc_roc(preds, actuals, returnDT=TRUE)
# }

Run the code above in your browser using DataLab