Computes the classification threshold that achieves a target sensitivity level on the ROC curve. This is essential when using ROC-based optimization objectives like metric_specificity_at_sensitivity(), where the optimization finds panels that perform well at a specific sensitivity level, but the default evaluation cutoff (0.5) may correspond to a different operating point.

find_threshold_for_sensitivity(
  panel,
  x,
  y,
  target_sensitivity = 0.9,
  positive = NULL,
  feature_transform = NULL,
  assay = NULL
)

Arguments

panel

A BiomarkerPanelResult.

x

Validation feature matrix, or a list of matrices for multi-cohort evaluation.

y

Validation binary response factor, or a list of factors when x is a list.

target_sensitivity

The desired sensitivity level (default 0.90). Must be between 0 and 1.

positive

Label treated as the positive class. Defaults to the value stored in the panel, or "Yes".

feature_transform

Optional feature transform name. Defaults to the transform stored in the fitted panel.

assay

For SummarizedExperiment inputs, assay name or index.

Value

A list with:

threshold

The cutoff probability that achieves the target sensitivity

sensitivity

The actual sensitivity at this threshold (may differ slightly from target due to discrete ROC points)

specificity

The specificity achieved at this threshold

target_sensitivity

The requested target sensitivity

auc

The full AUC of the ROC curve

See also

evaluate_panel() to evaluate with a specific cutoff, metric_specificity_at_sensitivity() for the optimization objective.

Examples

# After optimizing with specificity_at_sensitivity objective:
# result <- optimize_panel(x, y, objectives = build_objectives(
#   metrics = c("specificity_at_sensitivity", "num_features")
# ))
#
# Find the threshold for 90% sensitivity:
# thresh_info <- find_threshold_for_sensitivity(result, x_val, y_val)
#
# Evaluate at that threshold:
# eval <- evaluate_panel(result, x_val, y_val, cutoff_prob = thresh_info$threshold)