Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

auc

Area under curve of predicted binary response


Description

Takes in actual binary response and predicted probabilities, and returns auc value

Usage

auc(y, yhat)

Arguments

y

actual binary response

yhat

predicted probabilities corresponding to the actual binary response

Details

Area under the receiver operating characteristic (ROC) curve is the most sought after criteria for judging how good model predictions are.

auc function calculates the true positive rates (TPR) and false positive rates (FPR) for each cutoff from 0.01 to 1 and calculates the area using trapezoidal approximation. A ROC curve is also generated.

Value

area under the ROC curve

Author(s)

Akash Jain

See Also

Examples

# A 'data.frame' with y and yhat
df <- data.frame(y = c(1, 0, 1, 1, 0, 0, 1, 0, 1, 0),
                 yhat = c(0.86, 0.23, 0.65, 0.92, 0.37, 0.45, 0.72, 0.19, 0.92, 0.50))

# AUC figure
AUC <- auc(y = df[, 'y'], yhat = df[, 'yhat'])

StatMeasures

Easy Data Manipulation, Data Quality and Statistical Checks

v1.0
GPL-2
Authors
Akash Jain
Initial release
2015-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.