Confusion Matrix & Classification Metrics Calculator

Turn a confusion matrix into accuracy, precision, recall, F1, specificity, MCC and Cohen's κ, per class and averaged. Works for two classes or up to eight.

Results update as you type. Everything runs in your browser.

  1. 1. Pick a preset

    Click a preset (spam filter, sentiment, hallucination check) to fill in a matrix.

  2. 2. Or set your classes

    Choose 2–8 classes and rename them. Existing counts are kept when you resize.

  3. 3. Enter the counts

    Rows are the actual class, columns are what the model predicted.

  4. 4. Pick the positive class

    For two classes, choose which one counts as positive (for example Spam).

  5. 5. Read the metrics

    Results update as you type. Check precision and recall, not just accuracy.

Confusion matrix — rows: actual, columns: predicted

Actual ↓ / Predicted →

The diagonal (highlighted) holds the correct predictions. You can paste a matrix from Excel into any cell.

Accuracy
90.0%
Precision
90.9%
Recall
83.3%
F1
87.0%
MCC
0.791

Averages across classes

AveragePrecisionRecallF1
Macro0.9020.8890.894
Weighted0.9000.9000.899
Micro0.9000.9000.900

Overall scores — 150 predictions

Accuracy0.900
Error rate0.100
Balanced accuracy (mean recall)0.889
Matthews correlation (MCC)0.791
Cohen's kappa (κ)0.789
Majority-class baseline accuracy0.600

Binary scores for “Spam” as positive

Sensitivity / recall (TPR)0.833
Specificity (TNR)0.944
Precision (PPV)0.909
Negative predictive value (NPV)0.895
False positive rate0.056
False negative rate0.167

Results interpretation

The model got 90.0% of 150 predictions right. Always guessing the biggest class would score 60.0%, so the model adds real signal. For “Spam”, precision is 90.9% (how many of its alerts were right) and recall is 83.3% (how many real cases it caught), giving F1 = 0.870. MCC of 0.791 and κ of 0.789 indicate strong agreement.

The plain-English guide

A classifier makes mistakes, and the confusion matrix shows exactly which kind. Precision tells you how trustworthy its positive calls are, recall tells you how many real cases it finds, and F1 combines the two. Use them for spam filters, medical tests and LLM evaluations alike.

Key words, explained simply

Confusion matrix

A table of counts: rows are the true class, columns the predicted class. The diagonal is what the model got right.

TP / FP / FN / TN

True positive, false positive, false negative, true negative, counted for one class against all the others.

Accuracy

Correct predictions divided by all predictions. Misleading when one class dominates.

Precision

Of everything the model called positive, how much really was? TP / (TP + FP).

Recall (sensitivity)

Of everything that really was positive, how much did the model find? TP / (TP + FN).

F1 score

Harmonic mean of precision and recall. Low if either one is low.

Specificity

Of everything that really was negative, how much did the model call negative? TN / (TN + FP).

MCC and Cohen's κ

Single scores that stay honest on imbalanced data. 1 is perfect, 0 is no better than chance.

Macro / weighted / micro

Macro averages classes equally, weighted by class size, micro pools all counts (equals accuracy).

How this calculator works

For each class, TP is the diagonal cell, FP is the rest of its column, FN the rest of its row and TN everything else. Precision = TP/(TP+FP), recall = TP/(TP+FN), F-β = (1+β²)·P·R / (β²·P + R). Macro averages the classes equally, weighted uses class support, micro pools all counts and equals accuracy.

MCC and Cohen's κ use the multiclass formulas from the full matrix. Zero denominators return 0, matching scikit-learn's zero_division=0.

Common questions