Based on https://win-vector.com/2020/09/13/why-working-with-auc-is-more-powerful-than-one-might-think/
find_AUC_q( modelPredictions, yValues, ..., na.rm = FALSE, yTarget = TRUE, n_points = 101 )
modelPredictions | numeric predictions (not empty), ordered (either increasing or decreasing) |
---|---|
yValues | truth values (not empty, same length as model predictions) |
... | force later arguments to bind by name. |
na.rm | logical, if TRUE remove NA values. |
yTarget | value considered to be positive. |
n_points | number of points to use in estimates. |
q that such that curve 1 - (1 - (1-ideal_roc$Specificity)^q)^(1/q) matches area
d <- data.frame(pred = 1:4, truth = c(TRUE,FALSE,TRUE,TRUE)) q <- find_AUC_q(d$pred, d$truth) roc <- build_ROC_curve(d$pred, d$truth) ideal_roc <- data.frame(Specificity = seq(0, 1, length.out = 101)) ideal_roc$Sensitivity <- sensitivity_from_specificity_q(ideal_roc$Specificity, q) # library(ggplot2) # ggplot(mapping = aes(x = 1 - Specificity, y = Sensitivity)) + # geom_line(data = roc, color = "DarkBlue") + # geom_line(data = ideal_roc, color = "Orange") + # theme(aspect.ratio=1) + # ggtitle("example actual and ideal curve")