roc_curve: ROC curve.

View source: R/roc_proc.R

roc_curveR Documentation

ROC curve.

Description

Computes the receiver operating characteristic curve for binary classification predictions, using pROC::roc() as the backend.

Usage

roc_curve(truth, prob, positive = NULL)

Arguments

truth

Factor (or coercible to factor) of true class labels.

prob

Predicted probability of the positive class, or a probability matrix/data frame with one column per class level.

positive

Optional positive class level. Defaults to the second factor level.

Value

A funcml_roc object: a list with a curve data frame (threshold, sensitivity, specificity), the AUC, and the underlying pROC::roc object (proc).

Examples

if (requireNamespace("pROC", quietly = TRUE)) {
  set.seed(1)
  truth <- factor(rbinom(100, 1, 0.4))
  prob <- runif(100)
  roc_obj <- roc_curve(truth, prob)
  roc_obj$curve
}

funcml documentation built on Aug. 22, 2026, 5:08 p.m.