Threshold sweep analysis
Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/threshold-sweep-analysis
Use when when you have predicted probabilities and binary true labels from a classifier and need to evaluate its discriminative ability across multiple operating points, or when you need to generate a publication-quality ROC curve with AUC to compare classifiers or communicate model performance to.From its SKILL.md
npx -y skills add HolobiomicsLab/asb-skill-collections --skill threshold-sweep-analysisAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 14 stars14 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
5.6 KB, 892 tokens by cl100k_base, as published. Nobody here has run it
Threshold-sweep analysis
Summary
A method to compute performance metrics (true positive rate, false positive rate, and AUC) across a range of classification thresholds to characterize classifier behavior and generate ROC curves. This skill is essential for evaluating binary classification models when threshold selection affects sensitivity–specificity trade-offs.
When to use
When you have predicted probabilities and binary true labels from a classifier and need to evaluate its discriminative ability across multiple operating points, or when you need to generate a publication-quality ROC curve with AUC to compare classifiers or communicate model performance to stakeholders.
When NOT to use
- Input is already a pre-computed ROC curve or threshold-independent metric (e.g., Cohen's kappa, F1 score at a fixed threshold).
- Binary classification is not the task (e.g., multiclass or regression problems without one-vs-rest reformulation).
- True labels are missing, imbalanced to a degree that invalidates ROC interpretation, or contain noise that was not accounted for in classifier training.
Inputs
- CSV file with predicted probabilities and true binary labels (e.g., roc_example.csv)
Outputs
- ROC curve visualization (PNG or PDF file)
- AUC metric value
- True positive rate and false positive rate arrays across thresholds
How to apply
Load a CSV file containing predicted probabilities and true binary labels (e.g., roc_example.csv). Sweep across classification thresholds (typically 0 to 1 in increments of 0.01 or finer) and compute true positive rate (TPR) and false positive rate (FPR) at each threshold by comparing thresholded predictions against ground truth labels. Calculate the Area Under the Curve (AUC) metric by integrating the TPR-FPR curve using trapezoidal approximation or equivalent method. Render the ROC curve as a publication-quality figure with AUC displayed on the plot and save as PNG or PDF. Use R or Python statistical libraries (e.g., R's pROC package within Shiny) to automate these computations.
Related tools
- R Shiny (Interactive web framework for implementing ROC curve visualization and threshold-sweep UI; handles CSV upload, threshold parameter sweeps, and plot rendering.) — github.com/databio2022/GraphBio
Evaluation signals
- ROC curve monotonically increases from (0,0) to (1,1) in TPR vs. FPR space.
- AUC value lies in the range [0, 1], with 0.5 indicating random guessing and 1.0 perfect classification.
- Threshold sweep covers the full range [0, 1] with sufficient granularity (e.g., ≥100 points) to avoid visual stepping artifacts.
- Plot includes axis labels ('False Positive Rate', 'True Positive Rate'), legend with AUC value, and matches publication standards (e.g., vector format, readable fonts).
- Validation: recompute TPR and FPR at a subset of thresholds independently and confirm numerical agreement within machine precision.
Limitations
- ROC curves are insensitive to class imbalance; precision-recall curves may be more informative for highly imbalanced datasets.
- AUC assumes a single scalar score per sample; ties in predicted probabilities can affect threshold-sweep accuracy if not handled carefully.
- Threshold selection for deployment must consider the specific cost matrix or business constraints; ROC analysis alone does not prescribe an optimal threshold.
Evidence
- [other] Load the ROC demo CSV (roc_example.csv) containing predicted probabilities and true labels.: "Load the ROC demo CSV (roc_example.csv) containing predicted probabilities and true labels."
- [other] Calculate the ROC curve by computing true positive rate and false positive rate across classification thresholds using R or Python statistical libraries.: "Calculate the ROC curve by computing true positive rate and false positive rate across classification thresholds using R or Python statistical libraries."
- [other] Compute the Area Under the Curve (AUC) metric from the ROC curve.: "Compute the Area Under the Curve (AUC) metric from the ROC curve."
- [other] Render the ROC curve as a publication-quality figure with AUC displayed on the plot and save as a PNG or PDF file.: "Render the ROC curve as a publication-quality figure with AUC displayed on the plot and save as a PNG or PDF file."
- [readme] roc_example.csv for ROC curve: "roc_example.csv for ROC curve"
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.