Skip to contents

Computes the area under the ROC curve (AUC) for binary classification.

Usage

auc(o, p)

Arguments

o

Numeric vector of actual binary labels (0 or 1). Must have the same length as p.

p

Numeric vector of predicted probabilities (typically 0 to 1). Must have the same length as o.

Value

Numeric value between 0 and 1 representing the AUC. Higher values indicate better classification performance, with 0.5 indicating random performance and 1.0 indicating perfect classification.

Examples


auc(
  o = c(0, 0, 1, 1),
  p = c(0.1, 0.6, 0.4, 0.8)
  )
#> [1] 0.75