auc_roc: Area Under the ROC Curve

Description Usage Arguments Details References Examples

Description

Calculates Area Under the ROC Curve

Usage

1
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

1
2
3
4
5
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)

Example output

[1] 0.875
   Pred CountFalse CountTrue CumulativeFPR CumulativeTPR AdditionalArea
1:  0.9          0         1           0.0           0.5          0.000
2:  0.3          1         1           0.5           1.0          0.375
3:  0.1          1         0           1.0           1.0          0.500
   CumulativeArea
1:          0.000
2:          0.375
3:          0.875

mltools documentation built on May 2, 2019, 5:22 a.m.