How this instrument works
Matthews correlation coefficient (MCC) is a single number summarising how well a binary classifier performed, built from all four cells of a confusion matrix at once: true positives (TP), false positives (FP), true negatives (TN), and false negatives (FN). Originally proposed by biochemist Brian Matthews in 1975 to compare predicted and observed protein secondary structure, it behaves like a correlation coefficient between the predicted and actual classifications — +1 means perfect agreement, 0 means the classifier is no better than random guessing, and -1 means total disagreement.
What sets MCC apart from accuracy is that it only scores well when the classifier does well across all four cells simultaneously. Accuracy can look excellent on an imbalanced data set even when a model completely ignores the minority class, but MCC's denominator involves every row and column sum of the confusion matrix, so a classifier that predicts one class almost exclusively gets penalised even if it happens to be right most of the time by volume.
That property has made MCC the metric of choice in fields like bioinformatics and increasingly in general machine-learning evaluation, wherever the positive and negative classes are unevenly sized — rare-disease detection, fraud detection, defect detection — and a single trustworthy number is needed to compare models fairly.
- Enter the count of correctly flagged positive cases into True positives (TP).
- Enter the count of negative cases wrongly flagged as positive into False positives (FP).
- Enter the count of correctly cleared negative cases into True negatives (TN).
- Enter the count of positive cases wrongly cleared as negative into False negatives (FN).
- Read Matthews correlation coefficient (MCC) — a score from -1 (total disagreement) through 0 (no better than chance) to +1 (perfect classification).
- If any confusion-matrix row or column sums to zero — for example no actual positives at all — MCC's denominator is zero and the instrument will report it as undefined rather than force a result.
Worked example — the same 95-case confusion matrix
Enter TP = 50, FP = 10, TN = 30, FN = 5. The numerator is TP×TN − FP×FN = 50×30 − 10×5 = 1500 − 50 = 1450. The denominator is √[(50+10)(50+5)(30+10)(30+5)] = √[60 × 55 × 40 × 35] = √4,620,000 ≈ 2149.42. MCC reads 0.674601 — a strongly positive score, meaning the classifier's predictions and the true labels are substantially correlated.
Compare this to the same matrix's accuracy of 0.842105: both numbers say the classifier is performing well, but MCC folds in the fact that the classifier's errors (10 false positives, 5 false negatives) are unevenly spread across both classes, which a plain accuracy figure doesn't directly reveal.
Questions
Why use Matthews correlation coefficient instead of accuracy?
Accuracy treats every prediction equally, so it can look artificially high on an imbalanced data set even when a classifier ignores the minority class entirely. MCC uses all four confusion-matrix cells in both its numerator and denominator, so a classifier only scores well on MCC if it correctly handles positives and negatives in reasonable proportion to how often they actually occur — making it much harder to game with a lazy, majority-class-only strategy.
What does an MCC of 0 mean?
An MCC of exactly 0 means the classifier's predictions show no correlation with the true labels — statistically equivalent to random guessing given the class proportions in the data. It doesn't necessarily mean the classifier is wrong about everything; it means its right and wrong calls aren't distinguishable from chance once you account for how the classes are actually distributed.
Can MCC be calculated when one confusion-matrix cell is zero?
Usually yes — a single zero cell (say, zero false positives from a very strict classifier) is fine as long as no entire row or column of the matrix sums to zero. MCC becomes undefined only when TP+FP, TP+FN, TN+FP, or TN+FN sums to zero, because that makes the denominator zero — for example, if there are no actual positive cases in the data at all (TP+FN = 0), MCC cannot be computed.
Is MCC the same as a Pearson correlation coefficient?
Mathematically, yes — MCC is exactly the Pearson correlation coefficient computed between the vector of true labels and the vector of predicted labels, when both are coded as 0/1. That's what gives MCC its intuitive -1 to +1 scale and its behaviour as a genuine measure of association rather than a simple hit-rate ratio.
How does MCC compare with the F1 score?
The F1 score only uses TP, FP, and FN — it ignores true negatives entirely, which can make it misleading when the negative class matters. MCC uses all four cells, so it responds to changes in true negatives that F1 can't see. Research comparing the two metrics (Chicco & Jurman, 2020) found MCC gives a more informative and less easily inflated summary than F1 or plain accuracy on imbalanced binary classification tasks.