Every sample below carries a true class (positive or negative, drawn from two overlapping Gaussian score distributions) and a continuous score. The red line is the decision threshold t: everything scoring at or above it is predicted positive, everything below is predicted negative. Cross-referencing that prediction against the true class for every single sample is exactly how the 2x2 confusion matrix below is built — this simulator actually counts each sample, it does not interpolate a formula.
TP = true positive AND predicted positive
FP = true negative AND predicted positive
FN = true positive AND predicted negative
TN = true negative AND predicted negative
Precision = TP / (TP + FP)
Recall = TP / (TP + FN)
F1 = 2 · Precision · Recall / (Precision + Recall)
Accuracy = (TP + TN) / (TP + FP + FN + TN)
- Drag the threshold — either on the slider or directly on the red line in the plot — and watch every stat box recompute from a fresh count, not a cached curve. Moving right shrinks the "predicted positive" region: FP drops (fewer negatives cross it) but FN grows (fewer true positives cross it too).
- Jump to best F1 — scans every distinct score in the current sample as a candidate threshold and jumps to whichever one maximizes F1, the harmonic mean that only rewards a threshold that keeps precision and recall balanced together.
- Precision vs. recall tension — pushing the threshold up always raises precision (or leaves it equal) and never raises recall; pushing it down does the reverse. There is no threshold that maximizes both at once when the two distributions overlap.
- Accuracy can mislead — lower the positive prior toward 0.05 and watch accuracy stay high even at a threshold that catches almost no positives: with few positives in the data, correctly labeling the negative majority "for free" inflates accuracy while recall collapses.
Real-world relevance: choosing a single deployed threshold for a fraud filter, a spam gate or a diagnostic test is exactly this trade — reading the confusion matrix at that one operating point, not just a summary score, is what a reviewer actually needs to sign off on it.