Matthews Correlation Calculator
The Matthews correlation coefficient is the single number a confusion matrix deserves: it uses all four cells, stays honest under class imbalance, and behaves like a correlation — +1 perfect, 0 no better than chance, −1 perfectly wrong. Enter the four counts and this calculator returns MCC alongside the familiar rates, so the comparison makes its own argument.
Why One Number, and Why This One
Every other headline metric reads half the matrix. Accuracy ignores which errors were made; precision never sees a false negative; recall never sees a false positive; F1 ignores true negatives entirely — a startling omission in medicine and fraud, where the negatives are most of the world. MCC is, mathematically, the Pearson correlation between the true labels and the predicted labels, and that pedigree gives it its three virtues at once: it uses all four cells, it is symmetric (swap which class you call “positive” and the value is unchanged in magnitude — F1 cannot say that), and it is chance-anchored: a classifier guessing at the base rate scores about 0 however imbalanced the data, so the number cannot be inflated by prevalence. When a single figure must summarise a classifier — in a paper’s abstract, a model’s release notes, a clinician’s comparison — the literature’s recommendation, increasingly insistent since Chicco and Jurman’s advocacy, is this one.
Worked Example: A Good but Imperfect Classifier
The defaults describe a respectable diagnostic: TP 80, TN 70, FP 10, FN 40 — n = 200. Numerator: 80 × 70 − 10 × 40 = 5,600 − 400 = 5,200. Denominator: √((90)(120)(80)(110)) = √95,040,000 ≈ 9,748.8. MCC ≈ 0.533 — moderate, by the note’s bands. Compare the flattery of the other lines: accuracy prints 75.0%, precision a handsome 88.9%, but recall is only 66.7% — the test misses a third of the cases — and MCC’s 0.533 is the one figure that has priced that miss alongside everything else. Now run the majority-class fraud from the Accuracy page’s paradox beside it: on a 1%-prevalence test the all-negative classifier scores 99% accuracy and an MCC of undefined-to-zero honesty, because its empty positive column gives the correlation nothing to hold. The contrast is the calculator’s entire argument, runnable in two entries.
Reading MCC Like a Correlation
Because MCC is a correlation, its scale inherits correlation’s intuitions — and its relationship to the chi-square test on the same table is exact: MCC² = χ² ÷ n. A few reading habits follow. Treat 0.5 as you would treat r = 0.5: a real, substantial association that still leaves most of the variance unaccounted — a good screening test, not an oracle. Treat comparisons across datasets with different prevalences cautiously even for MCC (it is robust to imbalance, not indifferent to it: the attainable maximum shrinks as margins skew). And report the matrix alongside the coefficient, always — MCC’s virtue is honesty, not omniscience, and four counts are cheap to print. The calculator emits the companion rates for exactly that reason: the single number for the headline, the matrix’s other voices for the record.
A Note on Origins
The coefficient carries a biochemist’s name into machine learning: Brian Matthews introduced it in 1975 to score predictions of protein secondary structure, a problem where the interesting class is rare and the negatives are legion — the imbalance regime in which accuracy lies most fluently, half a century before imbalanced classification became an industry. Its migration into machine learning’s mainstream came with the field’s own imbalance era, and its advocacy literature (notably Chicco and Jurman’s 2020 case for MCC over accuracy and F1 in evaluating classifiers) reads like a rediscovery of Matthews’ original motivation. Instruments outlive their first problems when they answer a permanent question; “how good is this two-way prediction, all cells counted?” is permanent.
Thresholds: MCC Is Computed After the Cut
Most classifiers do not emit labels; they emit scores, and a threshold converts scores to the matrix this page consumes. Every threshold yields a different matrix and a different MCC, which makes MCC a tool for choosing the operating point as much as for summarising it: sweep the threshold, compute MCC at each, and the maximum marks the cut where the classifier’s overall correlation with truth peaks — a principled alternative to maximising accuracy (which drifts toward the majority class) or F1 (which ignores the negatives the threshold is busy creating). The caveat is the statistician’s standard one: a threshold tuned on the test set is a test set memorised, so the sweep belongs on validation data, with the calculator’s figure reserved for the untouched evaluation at the end.
The Geometry Under the Formula
One more way to feel what MCC measures: it is the cosine-like alignment between two binary vectors — the truth and the prediction laid side by side as strings of 0s and 1s — centred on their means. Perfect agreement aligns them exactly (correlation 1); a predictor uncorrelated with truth wanders at right angles to it (0); systematic inversion anti-aligns (−1, the signature of a sign error or an inverted label somewhere in the pipeline, and a genuinely useful alarm — a strongly negative MCC is information, not failure). This geometric reading explains the metric’s famous fairness: centring removes each vector’s base rate before the alignment is measured, so neither the prevalence of the truth nor the trigger-happiness of the predictor can inflate the angle’s cosiness. The four counts are the coordinates; the correlation is the angle.
MCC in Model Cards and Papers
Where a decade ago abstracts led with accuracy, reporting standards for classifiers increasingly ask for MCC by name — medical-AI checklists and benchmark leaderboards among them — because reviewers have learned what the accuracy paradox does to a 99%-accurate, zero-skill model on a rare disease. The practical guidance matches this page’s design: quote MCC with its confidence interval, name the threshold that produced the matrix, publish the matrix itself (four small integers that let any reader recompute everything on this page), and keep accuracy in the report for continuity with older literature, demoted to supporting cast. A result section built that way cannot be embarrassed by its own numbers, which is the entire editorial point.
Related Tools
More from the Statistics Calculators hub: the Accuracy Calculator, which prices the same four counts rate by rate, and the Spearman’s Correlation Calculator for correlation in its rank form.
Frequently Asked Questions
What is a good MCC score?
The note’s bands are the working answer — 0.7 and above is strong for most applied work, 0.5–0.7 moderate, below 0.3 weak — with the correlation reader’s caveat that fields differ: an MCC of 0.5 on a genuinely hard, noisy biological assay can be a triumph, while 0.9 on a benchmark with leaked labels is a scandal wearing a medal. Judge the coefficient against the task’s difficulty and the cost of each error type, which the single number deliberately blends but the underlying matrix still itemises.
Why is MCC undefined when a row or column is empty?
Because correlation is undefined when one variable never varies: if the classifier never predicts positive (TP + FP = 0) or the test set contains no positives (TP + FN = 0), a denominator factor is zero and the formula has no value — not zero skill, but no measurement. Software that prints 0 in this case is making a silent editorial decision; this calculator names the situation instead, since a test set with one class only is a design error the user should hear about, not a score.
MCC or F1 — which should I report?
Both, ideally, with the matrix — but if the venue allows one, MCC whenever true negatives carry meaning (screening, diagnosis, fraud, quality control: most real deployments), and F1 where negatives are truly background (retrieval-style tasks where TN is unbounded and meaningless). The asymmetry test decides: if relabelling the classes would change your F1 story but the problem feels unchanged, F1 was measuring the label, not the classifier. MCC passes that test by construction.
Does MCC handle multiclass problems?
Yes — it generalises (the Rk statistic) to a correlation over the full K×K confusion matrix, and the multiclass version keeps the same chance-anchored reading. This page prices the binary case, which remains the overwhelming share of reported matrices; a multiclass figure quoted from the generalisation should be named as such, since binary and multiclass MCCs on related problems are not interchangeable numbers despite sharing a surname and a scale.
How does MCC relate to Cohen’s kappa?
Both are chance-corrected agreement measures on the same table, and they usually rank classifiers identically; they differ in what “chance” means — kappa corrects by the agreement expected from the two margins independently, MCC is the literal correlation. On imbalanced tables kappa can behave counterintuitively (the kappa paradoxes: high agreement, low kappa), where MCC stays readable. For classifier evaluation the field has largely moved to MCC for exactly that robustness; kappa remains the dialect of inter-rater reliability studies, where its chance model matches the question.
What sample size does MCC need to be trustworthy?
The coefficient is computable from any n, but its sampling wobble at small n is correlation-sized: with n = 20, an MCC of 0.5 comes with a confidence interval wide enough to include near-zero. Report intervals for consequential comparisons (bootstrap over cases is the practical route), and treat leaderboard gaps smaller than the intervals as ties. The calculator’s exactness is about the arithmetic; the statistics of the estimate are the user’s design responsibility, as the chi-square kinship in the reading section hints.