set.seed(1)
AUC(c(0, 0), 0:1) # Equality of scores
AUC(c(0.2, 0.1, 1), c(0, 0, 1)) # Perfect AUC
x <- rnorm(100)
z <- rnorm(length(x), x, abs(x))
y <- as.numeric(z > 0)
print(AUC(x, y))
print(AUCBoot(x, y))
# Partial AUC
pAUC <- function(pred, target, p = 0.1) {
val.min <- min(target)
q <- quantile(pred[target == val.min], probs = 1 - p)
ind <- (target != val.min) | (pred > q)
bigstatsr::AUC(pred[ind], target[ind]) * p
}
pAUC(x, y)
pAUC(x, y, 0.2)
Run the code above in your browser using DataLab