find_AUC_q: Find area matching polynomial curve.

View source: R/ROC.R

find_AUC_qR Documentation

Find area matching polynomial curve.

Description

Based on https://win-vector.com/2020/09/13/why-working-with-auc-is-more-powerful-than-one-might-think/

Usage

find_AUC_q(
  modelPredictions,
  yValues,
  ...,
  na.rm = FALSE,
  yTarget = TRUE,
  n_points = 101
)

Arguments

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.

Value

q that such that curve 1 - (1 - (1-ideal_roc$Specificity)^q)^(1/q) matches area

Examples


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")


sigr documentation built on Aug. 20, 2023, 9:06 a.m.