Register a metric function.

register_metric(
  name,
  fun,
  direction = c("maximize", "minimize"),
  label = name,
  cutoff_dependent = FALSE,
  overwrite = FALSE
)

Arguments

name

Unique identifier for the metric.

fun

Function implementing the metric. Must accept at least the arguments truth, scores, and selected.

direction

Either "maximize" or "minimize".

label

Human-readable name.

cutoff_dependent

Logical; if TRUE, the metric depends on a probability cutoff for classification (e.g., sensitivity, specificity). Cutoff-dependent metrics may not behave as expected in min_metric_constraint() because their values depend on the arbitrary cutoff_prob parameter.

overwrite

Logical; set to TRUE to replace an existing registration.

Value

Invisibly, the registered name.