About the Confusion Matrix & ROC-AUC Explorer
Written by MySimulator Team Β· Reviewed by MySimulator Editorial Review
Last updated: 20 July 2026
A binary classifier rarely outputs a hard label directly β it outputs a continuous score, and it is the choice of decision threshold that converts that score into a predicted class. Everything at or above the threshold is called "positive"; everything below is called "negative." Comparing those predictions against the true labels produces the confusion matrix: true positives (TP), false positives (FP), true negatives (TN) and false negatives (FN). Every standard evaluation metric β precision, recall, specificity, F1 β is just an arithmetic combination of those four counts, and every one of them changes as you move the threshold.
This simulator generates two overlapping synthetic score distributions β one for the true negative class, one for the true positive class β and lets you drag the threshold across them while the confusion matrix updates live. Sweeping the threshold from its maximum down to its minimum and plotting the resulting true-positive-rate against the false-positive-rate at every step traces the ROC curve; the area under that curve (AUC) is a genuinely computed, threshold-independent summary of how separable the two classes are. Because ROC's false-positive-rate axis is normalized by the (often huge) negative count, it can look deceptively good on imbalanced data β the precision-recall curve, which normalizes by predicted positives instead, is shown alongside it for exactly that reason.
Frequently Asked Questions
What is a confusion matrix?
A confusion matrix is a 2Γ2 table that cross-tabulates a binary classifier's predicted labels against the true labels: true positives (TP, correctly predicted positive), false positives (FP, predicted positive but actually negative), true negatives (TN, correctly predicted negative), and false negatives (FN, predicted negative but actually positive). Every threshold-based accuracy metric β precision, recall, F1, specificity β is computed directly from these four counts.
How is the ROC curve constructed from a threshold sweep?
The ROC (Receiver Operating Characteristic) curve is built by sweeping the decision threshold from its highest value down to its lowest, recomputing the confusion matrix at every step, and plotting the resulting false positive rate (x-axis) against the true positive rate (y-axis) at each threshold. At a very high threshold almost nothing is predicted positive, so both rates start near (0,0); as the threshold drops toward the minimum score, everything gets predicted positive and the curve ends at (1,1).
What does AUC actually measure, and what do 0.5 and 1.0 mean?
AUC is the area under the ROC curve, equivalent to the probability that a randomly chosen positive example receives a higher score than a randomly chosen negative example. An AUC of 0.5 means the classifier is no better than random guessing (the ROC curve sits on the diagonal); an AUC of 1.0 means perfect separation β every positive scores higher than every negative. Because it is computed by sweeping all thresholds, AUC summarizes classifier quality independent of any single operating point.
Why do precision-recall curves matter more for imbalanced datasets than ROC curves?
The false positive rate used in ROC curves is normalized by the number of negatives, which is huge in an imbalanced dataset β so even a large number of false positives can look like a tiny FPR and the ROC-AUC stays deceptively high. Precision, used in the precision-recall curve, is normalized by the number of predicted positives instead, so it directly exposes how often a positive prediction is wrong. When positives are rare, the precision-recall curve is the more honest picture of performance.
What is the difference between precision and recall (TPR)?
Recall (also called true positive rate or sensitivity) is TP / (TP + FN) β of all the actual positives, what fraction did the classifier catch. Precision is TP / (TP + FP) β of everything the classifier flagged as positive, what fraction was actually positive. Raising the decision threshold typically increases precision (fewer, more confident positive calls) while lowering recall (more real positives get missed), and vice versa.
What is the F1 score and when should I use it?
F1 is the harmonic mean of precision and recall: 2 Γ precision Γ recall / (precision + recall). Unlike a simple average, the harmonic mean is dragged down heavily by whichever of the two is smaller, so F1 only stays high when both precision and recall are reasonably high. It is a useful single-number summary at one specific threshold when you care about positives and cannot tolerate either metric collapsing, especially on imbalanced data where plain accuracy is misleading.
How does moving the decision threshold trade off false positives against false negatives?
Raising the threshold makes the classifier more conservative: fewer examples are predicted positive, which shrinks false positives but grows false negatives. Lowering the threshold does the opposite: more examples are predicted positive, catching more true positives but also letting in more false positives. There is no threshold that minimizes both simultaneously when the two score distributions overlap β the choice depends on which error is more costly in the application.
Why does class separation change the shape of the ROC curve?
Class separation controls how far apart the mean scores of the positive and negative distributions are. When the distributions barely overlap, almost any threshold cleanly divides the two classes, so TPR rises much faster than FPR as the threshold sweeps down, bowing the ROC curve toward the top-left corner and pushing AUC toward 1.0. When the distributions overlap heavily, no threshold separates them well, TPR and FPR rise together, and the curve collapses toward the diagonal, with AUC approaching 0.5.