R/evaluate_sensitivity.R
find_threshold_for_sensitivity.RdComputes 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
)A BiomarkerPanelResult.
Validation feature matrix, or a list of matrices for multi-cohort evaluation.
Validation binary response factor, or a list of factors when x is
a list.
The desired sensitivity level (default 0.90). Must be between 0 and 1.
Label treated as the positive class. Defaults to the value
stored in the panel, or "Yes".
Optional feature transform name. Defaults to the transform stored in the fitted panel.
For SummarizedExperiment inputs, assay name or index.
A list with:
The cutoff probability that achieves the target sensitivity
The actual sensitivity at this threshold (may differ slightly from target due to discrete ROC points)
The specificity achieved at this threshold
The requested target sensitivity
The full AUC of the ROC curve
evaluate_panel() to evaluate with a specific cutoff,
metric_specificity_at_sensitivity() for the optimization objective.
# 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)