pr_auc: Precision-Recall Area Under the Curver (PR-AUC)

View source: R/metrics.R

pr_aucR Documentation

Precision-Recall Area Under the Curver (PR-AUC)

Description

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

Usage

pr_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 PR-AUC.

See Also

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

Examples

## Not run: 
pr_auc(factor(c("a", "b")), data.frame(a = c(0.2, 0.6), b = c(0.5, 0.4)))
pr_auc(factor(c("a", "b")), data.frame(a = c(0.8, 0.3), b = c(0.2, 0.7)))
pr_auc(
  factor(c("a", "b")),
  data.frame(a = c(0.2, 0.6), b = c(0.5, 0.4)),
  positive_class = "b"
)
pr_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.