roc_auc: ROC Area Under the Curver (ROC-AUC)

View source: R/metrics.R

roc_aucR Documentation

ROC Area Under the Curver (ROC-AUC)

Description

Given the observed values and predicted probabilities values of binary data computes the ROC Area Under the Curve (ROC-AUC).

Usage

roc_auc(observed, probabilities, positive_class = NULL, remove_na = TRUE)

Arguments

observed

(factor) The observed values. It has to have the same length as rows probabilities.

probabilities

(data.frame) The probability of each class for each individual. It is required the columns names of probabilities corresponds to all classes (levels) in observed and that probabilities has as many rows as records observed.

positive_class

(character(1)) The name of the class (level) to be taken as reference as the positive class. This parameter is only used for binary variables. NULL by default which uses the second class in the union of the classes (levels) in observed and predicted.

remove_na

(logical(1)) Should NA values be removed?. TRUE by default.

Value

A single numeric value with the ROC-AUC.

See Also

Other categorical_metrics: accuracy(), brier_score(), categorical_summary(), confusion_matrix(), f1_score(), kappa_coeff(), math_mode(), matthews_coeff(), pccc(), pcic(), pr_auc(), precision(), recall(), sensitivity(), specificity()

Examples

## Not run: 
roc_auc(factor(c("a", "b")), data.frame(a = c(0.2, 0.6), b = c(0.5, 0.4)))
roc_auc(factor(c("a", "b")), data.frame(a = c(0.8, 0.3), b = c(0.2, 0.7)))
roc_auc(
  factor(c("a", "b")),
  data.frame(a = c(0.2, 0.6), b = c(0.5, 0.4)),
  positive_class = "b"
)
roc_auc(
  factor(c(TRUE, FALSE)),
  data.frame(
    `TRUE` = c(0.3, 0.2),
    `FALSE` = c(0.7, 0.8),
    check.names = FALSE
  )
)

## End(Not run)


brandon-mosqueda/SKM documentation built on Feb. 8, 2025, 5:24 p.m.