auc: Calculate the area under the ROC curve

View source: R/auc.R

aucR Documentation

Calculate the area under the ROC curve

Description

Calculate the area under the ROC curve

Usage

auc(p_pred, label_true)

Arguments

p_pred

A vector of the predicted probabilities for the observations in the data set.

label_true

A vector containing the true class labels in the data set.

Value

The sample estimate of the area under ROC curve, realized based on a two- sample U-statistic estimator that is akin to the Mann-Whitney two-sample U-statistic. It is also the estimated probability that the binary classifier will score a randomly drawn positive sample higher than a randomly drawn negative sample.

References

H. B. Mann and D. R. Whitney (1947). On a test of whether one of two random variables is stochastically larger than the other. Annals of Mathematical Statistics 18: 50-60.

Examples

library(aucvar)
my_data <- na.omit(breastcancer) # Omit NA values
full_model <- glm(Class~`Clump Thickness`+ `Uniformity of Cell Size` +
`Uniformity of Cell Shape`+ `Marginal Adhesion` + `Single Epithelial Cell Size`
+ `Bare Nuclei` + `Bland Chromatin` + `Normal Nucleoli` + `Mitoses`,
 family=binomial(link="logit"), data=my_data)
prob <- predict(full_model, type="response")
labels <- my_data$Class
auc(prob, labels)


fmoyaj/aucvar documentation built on Nov. 28, 2023, 10:50 p.m.