Matthews correlation coefficient
For binary classification, the Matthews correlation coefficient is the Pearson correlation between predicted class labels and observed outcomes, calculated from all four confusion-matrix counts.
MCC = (TP*TN - FP*FN) / sqrt((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN)), where TP, FP, FN and TN count true positives, false positives, false negatives and true negatives in the same evaluation population. When defined, it ranges from -1 for complete disagreement to +1 for complete agreement; zero means zero binary correlation, not proof of a particular guessing mechanism. [1]
If either labels or predictions are constant, the denominator is zero and the correlation is undefined. scikit-learn 1.7.2 returns 0.0 in this case; Hesela's accompanying calculation returns null to keep that distinction visible. [2]
Relations
- related
- f1-score, precision, recall, false-positive-rate, class-prevalence, probability-calibration
Limitations
- MCC is not a failure probability or the fraction of correct alerts; report the positive event, horizon, threshold, counts and population alongside it. [1]
Citations
- scikit-learn: Matthews correlation coefficient and binary confusion-matrix formula.
- scikit-learn 1.7.2: matthews_corrcoef, zero-denominator convention.
Further reading
Published by Hesela team · Updated
Report a correction · Editorial standards · Reuse guidance
Cite this page
Hesela team. Matthews correlation coefficient. Hesela. 2026-10-17. https://hesela.dev/terms/matthews-correlation-coefficient/