Explorateur ROC et précision-rappel

Courbes ROC et précision-rappel interactives à partir de scores et d’étiquettes : déplacez le seuil, lisez la matrice de confusion, l’AUC, la précision moyenne, le F1, le MCC et le seuil optimal en coût.

About this tool

Turns a list of classifier scores and true labels into the two curves used to choose a decision threshold: the ROC curve and the precision-recall curve. Every distinct score becomes one operating point, so the curves, the AUC and the average precision are exact, not sampled.

Input: one case per line, score,label. The score is any real number (a probability, a logit, a distance); higher must mean “more likely positive”. Labels may be 1/0, yes/no, true/false or pos/neg. Comma, semicolon, tab and pipe separators are detected automatically, and a header line is ignored. Up to 20000 rows.

Threshold: the slider walks the operating points from “predict nothing positive” down to “predict everything positive”. A case counts as positive when its score is greater than or equal to the threshold. The confusion matrix, all metrics and the orange dot on both curves follow the slider.

Metrics

  • AUC — area under the ROC curve; the probability that a random positive scores above a random negative. 0.5 is chance, 1.0 is perfect.
  • Average precision — area under the precision-recall curve, computed as the sum of precision weighted by the change in recall.
  • TPR / recall / sensitivity = TP / (TP + FN); FPR = FP / (FP + TN); specificity = 1 − FPR.
  • Precision = TP / (TP + FP); NPV = TN / (TN + FN).
  • F1 — harmonic mean of precision and recall. MCC — Matthews correlation coefficient, the most informative single number on imbalanced data. Youden's J = TPR − FPR.
  • Expected cost — (cost per FP × FP + cost per FN × FN) divided by the number of cases.

Suggested cutoffs lists the threshold that maximises F1, the one that maximises Youden's J, the point closest to the perfect corner (0,1) on the ROC plot, and the one that minimises your expected cost. Press Use to move the slider there.

Why two curves: ROC ignores class balance, so on a rare-event problem a model can look excellent on ROC and still be useless in practice. Try the Imbalanced example: the AUC stays high while precision collapses, which is exactly what the precision-recall curve shows. The dashed baseline on the PR plot is the prevalence — the precision a coin flip would reach.

Example: with scores 0.9,1 / 0.8,0 / 0.7,1 / 0.2,0 the threshold 0.7 gives TP 2, FP 1, FN 0, TN 1 — recall 100%, precision 67%, F1 0.80.

Limitations: binary problems only, no confidence intervals on AUC, and the curves assume the scores are comparable across cases. For a multi-class model, export one score column per class and analyse them one at a time.