b2KIT

Confusion Matrix Analyzer

Build confusion matrices and compute precision, recall, F1-score, accuracy, and ROC curves with interactive threshold adjustment.

Tested tool guide Tested browser tools Checked August 16, 2026

What Confusion Matrix Analyzer does, with a checked example

Convert actual outcomes and model predictions into a confusion matrix, then inspect precision, recall, F1-score, and accuracy. When prediction scores are available, adjust the classification threshold to see how false positives and false negatives change and how those operating points form an ROC curve. The key trap is orientation: a matrix is easy to misread unless you confirm which class is positive and whether actual labels occupy rows or columns.

Worked example

A concrete input and expected output from the current implementation.

Input

True positives: 8
False positives: 2
False negatives: 2
True negatives: 8

Expected output

Confusion matrix, with actual rows and predicted columns: [[8, 2], [2, 8]]. Precision: 0.80. Recall: 0.80. F1-score: 0.80. Accuracy: 0.80.

Precision and recall are both 8 / 10. Sixteen of the 20 predictions are correct, so accuracy is 16 / 20, and equal precision and recall produce an F1-score of 0.80.

How the result is produced

1

Matrix-derived metrics

For a binary classifier, the four cells are true positives, false positives, false negatives, and true negatives. Precision is TP / (TP + FP), recall is TP / (TP + FN), F1 is the harmonic mean of precision and recall, and accuracy is (TP + TN) divided by all observations. A zero denominator makes the corresponding metric undefined.

2

Threshold and ROC

With labeled prediction scores, the selected threshold separates predicted positives from predicted negatives. Moving it changes the four confusion-matrix counts and therefore the displayed metrics. The ROC curve records true-positive rate against false-positive rate across thresholds. Its points describe different operating choices, not repeated measurements of one fixed confusion matrix.

Good uses

  • Checking a binary classifier before deployment by comparing its false positives and false negatives.
  • Choosing a score threshold when missing a positive case has a different cost from raising a false alarm.
  • Comparing candidate thresholds through precision, recall, F1-score, accuracy, and ROC position.

Limits and checks

  • Confirm the positive class and matrix orientation before interpreting any cell or class-specific metric.
  • Accuracy can appear strong on an imbalanced dataset even when the classifier rarely identifies the minority class.
  • A single confusion matrix contains only one operating point. It cannot determine an entire ROC curve without scores or results from additional thresholds.

Common questions

Does high accuracy mean the classifier is performing well?

Not necessarily. Accuracy weights every correct prediction equally, so a dominant class can hide poor detection of a rarer positive class. Inspect the underlying counts together with precision and recall. Whether the result is acceptable depends on the consequences of false positives and false negatives in the intended use.

Why do precision and recall change when I move the threshold?

The threshold changes which scored observations are labeled positive. Lowering it commonly admits more predicted positives, which can increase both true positives and false positives. Raising it commonly does the reverse. There is no universally best threshold; choose an operating point based on the error tradeoff relevant to the decision.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools