Calculate the area under the curve (AUC)

get_auc(roc)

Arguments

roc

a matrix or data frame with columns "FPR" and "TPR" containing pairs of false and true positive rates.#'

Examples

# simulate training and test data dat <- data.frame( cl = as.factor(rbinom(10, 1, 0.5)), x1 = rnorm(10), x2 = rbinom(10, 1, 0.3) ) model <- jdify(cl ~ x1 + x2, data = dat) # joint density fit probs <- predict(model, dat, what = "probs") # conditional probabilities # calculate performance measures assess_clsfyr(probs[, 1], dat[, 1] == 0, measure = c("ACC", "F1"))
#> threshold measure value #> 1 0.0 ACC 0.8000000 #> 2 0.1 ACC 0.8000000 #> 3 0.2 ACC 0.8000000 #> 4 0.3 ACC 0.8000000 #> 5 0.4 ACC 0.8000000 #> 6 0.5 ACC 0.8000000 #> 7 0.6 ACC 0.8000000 #> 8 0.7 ACC 0.4000000 #> 9 0.8 ACC 0.3000000 #> 10 0.9 ACC 0.3000000 #> 11 1.0 ACC 0.3000000 #> 12 0.0 F1 0.8888889 #> 13 0.1 F1 0.8888889 #> 14 0.2 F1 0.8888889 #> 15 0.3 F1 0.8888889 #> 16 0.4 F1 0.8888889 #> 17 0.5 F1 0.8888889 #> 18 0.6 F1 0.8888889 #> 19 0.7 F1 0.4000000 #> 20 0.8 F1 0.2222222 #> 21 0.9 F1 0.2222222 #> 22 1.0 F1 0.2222222
# calculate area under the curve FPR <- assess_clsfyr(probs[, 1], dat[, 1] == 0, measure = c("FPR"))$value TPR <- assess_clsfyr(probs[, 1], dat[, 1] == 0, measure = c("TPR"))$value get_auc(data.frame(FPR = FPR, TPR = TPR))
#> [,1] #> [1,] 0.5625