Confusion Matrix Analyzer
Analyze binary and multi-class classification results — accuracy, precision, recall, F1, specificity, MCC, and per-class metrics with a live confusion matrix heatmap. Free and browser-based.
Confusion Matrix Analyzer
Accuracy = (TP + TN) ÷ Total
Confusion Matrix Counts
What Is a Confusion Matrix Analyzer?
A confusion matrix analyzer is a free browser-based tool that evaluates classification model performance by comparing actual labels against predicted labels. It answers the question every model builder needs to answer before shipping: exactly where and how often is my model getting it wrong, and does that matter for my use case?
The tool supports both binary classification — enter True Positive, False Positive, False Negative, and True Negative counts directly — and multi-class classification, where you paste raw actual and predicted labels and let the calculator build the full confusion matrix, per-class metrics, and macro/weighted averages automatically.
This tool is built for data scientists, machine learning engineers, AI researchers, students, teachers, Kaggle competitors, business analysts, software engineers, and researchers. It supports CSV import, an interactive matrix heatmap, and CSV/TXT/JSON export — running entirely in your browser with no signup required.
How the Confusion Matrix Analyzer Works
In Manual Counts mode, the calculator applies the standard binary classification formulas directly to your TP, FP, FN, and TN values. In Actual vs. Predicted mode, it builds a full confusion matrix from your raw labels, then derives per-class and aggregate metrics from that matrix.
Core Formulas
Accuracy = (TP + TN) ÷ (TP + TN + FP + FN)
Precision = TP ÷ (TP + FP) · Recall = TP ÷ (TP + FN)
Specificity = TN ÷ (TN + FP) · F1 = 2PR ÷ (P + R)
MCC = (TP·TN − FP·FN) ÷ √((TP+FP)(TP+FN)(TN+FP)(TN+FN))
- →Automatic Class Detection: In Actual vs. Predicted mode, every unique label across both lists becomes a class in the matrix — no manual class list configuration required.
- →Per-Class Metrics: For multi-class data, precision, recall, and F1 are calculated separately for every class by treating each class as "positive" in turn against all others.
- →Macro, Weighted, and Micro Averages: Macro average treats every class equally; weighted average accounts for how many samples each class has; overall accuracy serves as the micro-averaged score for single-label classification.
- →Binary-Specific Metrics: When exactly two classes are detected, the calculator automatically also computes Specificity, NPV, FPR, FNR, Balanced Accuracy, and MCC using the second class as the positive class.
How to Use the Confusion Matrix Analyzer
Step-by-Step Guide
- 1Choose an Input Mode: Select Manual Counts for binary classification with known TP/FP/FN/TN totals, or Actual vs. Predicted Lists for multi-class analysis from raw labels.
- 2Enter or Import Your Data: Type your confusion matrix counts, paste two label lists (one label per line), or import a CSV file with Actual and Predicted columns.
- 3Enable Case-Insensitive Matching if Needed: Toggle this on if your labels might differ only in capitalization, such as "Cat" vs. "cat".
- 4Review the Confusion Matrix Heatmap: See exactly how many predictions fell into each actual-vs-predicted combination, with darker cells indicating higher counts.
- 5Check the Metrics Dashboard: Review accuracy, precision, recall, F1, and — for binary or two-class data — specificity, MCC, and balanced accuracy, plus a full per-class table for multi-class data.
- 6Copy or Export: Copy the metrics summary, download the full report as CSV, TXT, or JSON, or print a formatted report.
Key Features
- ✓Binary and multi-class classification support
- ✓Manual TP/FP/FN/TN entry, or raw label list analysis
- ✓CSV drag-and-drop / file import with Actual, Predicted columns
- ✓Automatic unique-class detection for multi-class data
- ✓Interactive confusion matrix heatmap
- ✓Per-class precision, recall, F1, and support table
- ✓Macro and weighted average aggregation
- ✓Binary-only metrics: specificity, NPV, FPR, FNR, MCC, balanced accuracy
- ✓Optional case-insensitive label matching
- ✓Row-count mismatch detection with a clear error message
- ✓Instant calculation with a 150ms debounce as you type
- ✓Export report as CSV, TXT, or JSON, plus a printable layout
- ✓All processing runs locally — no data leaves your browser
Real-World Use Cases
Evaluating a Binary Fraud Detector
A fraud analyst enters TP = 90, FP = 8, FN = 5, TN = 120 in Manual Counts mode. The calculator returns Accuracy = 94.17%, Precision = 91.84%, Recall = 94.74%, Specificity = 93.75%, and F1 = 93.27%, giving a full performance snapshot in one view.
Analyzing a Multi-Class Animal Classifier
A data scientist pastes actual labels (Cat, Dog, Dog, Cat, Bird) and predicted labels (Cat, Dog, Cat, Cat, Bird) into Actual vs. Predicted mode, instantly seeing which animal classes get confused with each other in the resulting matrix.
Importing Model Output from a CSV Export
A machine learning engineer exports predictions from their notebook as a CSV with Actual and Predicted columns, imports it directly, and gets the full confusion matrix and metrics without writing any evaluation code.
Comparing Balanced Accuracy vs. Raw Accuracy
A researcher working with an imbalanced medical dataset (TP = 15, FP = 2, FN = 8, TN = 300) compares the deceptively high 95.7% accuracy against the more honest 79.4% balanced accuracy, which properly accounts for the rare positive class.
Diagnosing Class Confusion in a Kaggle Submission
A competitor pastes their validation set's actual and predicted labels to see the per-class F1 breakdown, identifying which specific classes are dragging down their overall macro F1 score before their next submission.
Reporting MCC for an Imbalanced Binary Problem
A business analyst evaluating a rare-event churn model (TP = 12, FP = 3, FN = 18, TN = 467) reports the Matthews Correlation Coefficient of 0.42 alongside accuracy, since MCC gives a more trustworthy single number for this heavily imbalanced case.
Tips & Common Mistakes
Pro Tips
- 💡Use MCC instead of accuracy as your headline metric on imbalanced binary datasets — it accounts for all four confusion matrix cells and is much harder to game.
- 💡Check the per-class table, not just macro/weighted averages, when working with multi-class data — a strong overall F1 can still hide one class performing terribly.
- 💡Use weighted average when your classes are naturally imbalanced and you care about overall performance; use macro average when every class matters equally regardless of size.
- 💡Enable case-insensitive matching if your labels come from different sources that might format the same class differently, like "Positive" vs. "positive".
- 💡Always sanity-check row counts before analyzing — a silent row-count mismatch between Actual and Predicted would otherwise silently misalign every comparison.
Common Mistakes to Avoid
- ✕Don't rely on accuracy alone for imbalanced datasets — a model that always predicts the majority class can score deceptively high accuracy while being practically useless.
- ✕Don't forget that Specificity, NPV, FPR, FNR, and MCC are only computed for exactly two classes — for three or more classes, use the per-class precision/recall/F1 table instead.
- ✕Don't mix up macro and weighted averages when reporting results — they can tell very different stories on imbalanced data, so specify which one you're citing.
- ✕Don't paste mismatched Actual and Predicted lists expecting row-by-row alignment to just work — every row must correspond exactly, in the same order, between both lists.
- ✕Don't ignore the confusion matrix heatmap itself — aggregate metrics can mask specific, systematic confusions between particular class pairs that the raw matrix reveals immediately.
Confusion Matrix Metrics Reference
| Metric | Formula | What It Measures |
|---|---|---|
| Accuracy | (TP + TN) ÷ Total | Overall correctness across all predictions |
| Precision | TP ÷ (TP + FP) | How trustworthy positive predictions are |
| Recall | TP ÷ (TP + FN) | How many actual positives were found |
| Specificity | TN ÷ (TN + FP) | How well actual negatives are identified |
| F1 Score | 2PR ÷ (P + R) | Balance between precision and recall |
| MCC | See formula above | Overall quality accounting for all four cells |
Frequently Asked Questions
What is a confusion matrix analyzer?
A confusion matrix analyzer is a free browser-based tool that evaluates classification model performance by comparing actual and predicted labels, computing accuracy, precision, recall, F1, specificity, and MCC for both binary and multi-class problems.
What is a confusion matrix?
A confusion matrix is a table comparing actual class labels against predicted class labels, showing exactly how many predictions of each type were correct or incorrect. Binary classification has four cells: True Positive, False Positive, False Negative, and True Negative.
How is accuracy different from precision, recall, and F1?
Accuracy measures overall correctness across all predictions, including True Negatives. Precision and Recall focus specifically on positive predictions, and F1 balances the two — this distinction matters most on imbalanced datasets where accuracy alone can be misleading.
What is Matthews Correlation Coefficient (MCC)?
MCC is a balanced metric from -1 to +1 that accounts for all four confusion matrix values simultaneously, making it more reliable than accuracy or F1 alone for imbalanced binary classification. +1 means perfect prediction, 0 means no better than random guessing, and -1 means total disagreement.
How do I analyze multi-class classification results?
Switch to Actual vs. Predicted Lists mode and paste your actual and predicted labels, one per line, matched by row order. The calculator automatically detects every unique class, builds the full confusion matrix, and computes per-class and aggregate metrics.
What is the difference between macro and weighted averages?
Macro average computes the metric per class and takes the unweighted mean, treating every class equally. Weighted average weights each class by its number of samples (support), better reflecting performance on imbalanced datasets.
Can I upload a CSV instead of typing labels?
Yes. Import a CSV file with "Actual" and "Predicted" columns (case-insensitive header matching), and the calculator automatically extracts and loads both label lists.
What happens if my Actual and Predicted lists have different lengths?
The calculator immediately shows an error stating exactly how many rows each list contains, since a valid confusion matrix requires every prediction to be matched to exactly one actual label in the same order.
What do Specificity, NPV, FPR, and FNR mean?
Specificity measures how well actual negatives are correctly identified. NPV measures how many negative predictions were actually correct. FPR and FNR are the complements of Specificity and Recall, representing the model's error rates on negatives and positives respectively.
Is my data private when using this calculator?
Yes. All calculations run entirely in your browser using JavaScript. Your classification data, whether typed, pasted, or uploaded as a CSV, is never transmitted to any server, stored in any database, or accessible to anyone other than you.
Who Uses This Calculator?
Machine Learning Engineers
Diagnose model errors and validate performance before production deployment.
Data Scientists & AI Researchers
Generate standardized classification reports for experiments and publications.
Students & Teachers
Learn and teach confusion matrix concepts with instant, interactive examples.
Kaggle Competitors
Quickly diagnose which classes are being confused in a multi-class submission.
Business Analysts
Translate model output into plain metrics stakeholders can act on.
Software Engineers
Validate classifier behavior during QA before shipping to production.
Related Tools
Precision Calculator
Calculate the Precision metric from True Positive and False Positive counts, with percentage conversion and performance rating.
Recall Calculator
Calculate the Recall (Sensitivity) metric from True Positive and False Negative counts, with confusion matrix mode and performance rating.
F1 Score Calculator
Calculate the F1 Score from Precision and Recall, or directly from a confusion matrix (TP, FP, FN), with step-by-step breakdown and performance rating.
ROC AUC Calculator
Calculate the ROC curve and AUC score from binary classification results with an interactive curve, threshold explorer, and CSV upload.
P-Value Calculator
Calculate p-values and statistical significance for Z-tests, T-tests, Chi-Square tests, F-tests, and correlation tests instantly.
Correlation Coefficient Calculator
Calculate Pearson, Spearman, and Kendall correlation coefficients instantly with scatter plot visualization, regression line, outlier detection, and downloadable reports.