---
title: Matthews Correlation Coefficient (MCC)
url: https://www.emergentmind.com/topics/matthews-correlation-coefficient-mcc
type: topic
---

# Matthews Correlation Coefficient (MCC)

The Matthews Correlation Coefficient (MCC) is a scalar metric of confusion matrix performance, offering a balanced assessment of classification accuracy that remains informative under class imbalance. Originally formulated for binary classification and equivalent to the Pearson correlation coefficient between predicted and true binary labels, MCC is now a standard evaluation measure in machine learning, bioinformatics, medical imaging, and cyber-security research. Its rigorous symmetry properties, penalties for both types of misclassifications, and robust theoretical foundations have led to numerous generalizations and methodological advances, especially for multiclass and imbalanced settings.

## 1. Formal Definition, Correlation Interpretation, and Range

Given a binary confusion matrix with entries:
- True Positives (TP)
- True Negatives (TN)
- False Positives (FP)
- False Negatives (FN)

the Matthews Correlation Coefficient is

\[
\mathrm{MCC} =
\frac{TP \times TN - FP \times FN}
     {\sqrt{(TP + FP)(TP + FN)(TN + FP)(TN + FN)}}
\]

This metric takes values in \([-1, 1]\), where \(+1\) indicates perfect correlation (all predictions correct), \(0\) indicates performance no better than random, and \(-1\) represents total disagreement (systematic reversals between prediction and ground truth) [2010.13454, 2305.05974, 2003.01182, 2209.05355].

MCC is the sample Pearson correlation coefficient between the indicator vectors for ground truth and predictions, i.e.,

\[
\mathrm{corr}(Y, \hat{Y}) = \frac{\operatorname{Cov}(Y, \hat{Y})}{\sqrt{\operatorname{Var}(Y) \operatorname{Var}(\hat{Y})}}
\]

This means MCC captures both the tendency toward correct labeling and the symmetry between positive and negative classes [2209.05355].

Its symmetry properties include invariance under swapping positive/negative labels and under permuting predicted vs. true labels.

## 2. Class Imbalance, Decision-Theoretic Properties, and Limitations

MCC remains well-calibrated even as class frequencies become highly skewed, in contrast to accuracy or F1-score, which can be drastically inflated by the majority class [2003.01182, 2512.19203, 2209.05355]. Because it incorporates all four confusion-matrix entries, MCC penalizes classifiers that perform well only on the majority class but are ineffective on the minority class.

However, MCC is “Type IV symmetric” in the sense of cost-behavior analysis: it penalizes misclassification of the rare and the prevalent class equally—both misclassification costs scale as \(1 / [p_2(1 - p_2)]\), where \(p_2\) is the minority-class prevalence [1403.7100]. This means that MCC does not enforce the property that errors on the rare class carry higher cost, which is often desired in imbalanced learning. Alternative metrics, such as the balanced error rate (BER), do so by imposing asymmetric, prevalence-aware penalties.

In extremely negative-skewed regimes (\(TN \to \infty\)), MCC converges to the Fowlkes–Mallows index (FM):

\[
\lim_{TN \to \infty}\mathrm{MCC} = \sqrt{\mathrm{precision} \times \mathrm{recall}}
\]

Thus, in object detection or open-world tasks with intractable true-negative counts, FM can be reported as a stand-in for MCC [2305.00594].

## 3. Extensions: Multiclass, Weighted, and Robust Variants

### Multiclass Generalizations

Several multiclass extensions of MCC exist:

- **Gorodkin’s \(\mathrm{R}_K\):** Formulated via multi-dimensional Pearson correlation of one-hot label matrices, reducing to binary MCC for \(K=2\), but can be overly optimistic for “hollow” confusion matrices (complete misclassification) [2305.05974].
- **Determinant-Based Formulation:** For confusion matrix \(C\), the multi-class MCC is
  \[
  \mathrm{MCC}_K = \frac{\det(C)}{\sqrt{\prod_{i=1}^K t_i \prod_{j=1}^K p_j}}
  \]
  where \(t_i\), \(p_j\) are row and column sums, respectively [2208.05651].
- **Macro and Micro-Averaged MCC:** Compute binary MCC for each class vs. rest (macro), or pool confusion-matrix cells and apply binary MCC formula (micro). The “miM\(^*\)” approach ensures range \([-1,1]\) and proper correlation structure [2503.06450].
- **Enhanced Metrics:** Enhanced versions (ER\(_K\), EMPC\(_1\), EMCC) are designed to reach \(-1\) under maximally poor (hollow) confusion matrices and to handle class imbalance more sensitively [2305.05974].
- **Weighted MCC:** Incorporates distinct observation weights for binary and multiclass settings, maintaining the same range and providing stability under small perturbations in observed weights [2512.20811].

### Robustified MCC for Imbalanced Problems

The standard MCC is not robust against class imbalance in the sense that, as the minority class proportion \(\pi \to 0\), the Bayes-optimal classifier can essentially ignore the minority class, resulting in true-positive rates tending to zero [2404.07661]. To address this, Holzmann and Klar introduce a robustified MCC:

\[
\mathrm{MCC}_{\mathrm{rb}} = \frac{\pi_{11}\,\pi_{00} - \pi_{01}\,\pi_{10}}
      {\sqrt{ \pi(1-\pi)\,( d + \gamma(1 - \gamma) ) }}
      \left( \frac{d}{\pi(1-\pi)} + 1 \right)^{1/2}
\]

for small \(d > 0\), ensuring TPR is bounded below under any class imbalance [2404.07661].

## 4. Statistical Inference: Confidence Intervals and Variance Estimation

The sampling variability of MCC is nontrivial, particularly under class-imbalance. The asymptotic distribution can be derived by the delta method, employing the multiclass multinomial model for cell probabilities:

\[
\sqrt{n} (\hat{\mathrm{MCC}} - \mathrm{MCC}) \xrightarrow{d} N(0, \sigma^2)
\]

where \(\sigma^2\) involves the gradient of MCC with respect to cell probabilities and empirical covariance [2405.12622, 2503.06450]. Explicit expressions for the partial derivatives are available, facilitating computation of standard errors.

Fisher’s z-transformation, \(z = \frac{1}{2} \ln \frac{1 + \mathrm{MCC}}{1 - \mathrm{MCC}}\), reduces skewness and improves coverage of confidence intervals, especially for small samples or in the presence of strong imbalance.

For paired study designs—comparing two classifiers on the same subjects—delta-method-based and transformation-based CIs are available for the difference in MCCs [2405.12622, 2503.06450].

## 5. Empirical Motivation, Applications, and Best Practices

MCC addresses reproducibility failures and misleading conclusions in classification research, especially where F1 or accuracy can be either arbitrary or misrepresentative. Yao & Shepperd demonstrate that classifier ranking by F1 and MCC disagrees in 23% of defect prediction experiments; the difference is more pronounced for similar F1 values [2003.01182].

MCC is especially advocated in:
- Software defect prediction, where defect-prone modules are rare [2003.01182].
- Medical imaging, including lesion segmentation, where background dominates [2010.13454].
- Intrusion detection, where cyber-attacks are low-frequency events [2512.19203].

Under severe imbalance, accuracy may be misleadingly high despite total failure to detect the minority class; MCC collapses to zero in such cases, reflecting genuine lack of discrimination [2512.19203].

Best practices:
- Report the full confusion matrix, permitting recomputation of MCC and related metrics.
- For binary settings, prefer MCC over F1, accuracy, or AUROC when class sizes are skewed.
- In multiclass settings, use macro- and micro-averaged or determinant-based MCCs, considering enhanced variants under severe misclassification.
- Use Fisher’s z-intervals or delta-based CIs for inferential assessments, especially for method comparisons [2503.06450, 2405.12622].

## 6. Methodological Advances and Loss Functions in Deep Learning

The differentiable version of MCC enables its direct use as a loss function in deep learning. By expressing confusion-matrix counts as differentiable sums of predicted probabilities and labels, one obtains a continuous “MCC loss,” suitable for gradient-based optimization:

\[
\mathcal{L}_{\mathrm{MCC}} = 1 - \mathrm{MCC}(\{\hat y_i\}, \{y_i\})
\]

where \(\hat y_i \in [0,1]\) are soft predictions. This loss back-propagates cleanly, preserving the full class-imbalance sensitivity of MCC [2010.13454]. Empirical studies in skin lesion segmentation confirm that MCC-loss outperforms Dice-loss and other imbalance-agnostic losses, yielding consistent improvements in Jaccard, Dice, and accuracy metrics [2010.13454].

## 7. Related Metrics, Curves, and Limitations

MCC is contrasted with other commonly-used metrics:

- **F1-score:** Ignores true negatives; can result in identical F1 for classifiers with vastly different abilities to reject the majority class [2003.01182].
- **Precision–Recall, ROC curves:** These can be insensitive or misleading under extreme imbalance. The MCC–F1 curve provides a comprehensive visualization by plotting normalized MCC vs. F1 across thresholds and choosing an optimal threshold based on Euclidean distance to the perfect corner; it robustly differentiates classifier performance independent of class skew [2006.11278].
- **Confusion Entropy (CEN):** Strongly (almost monotonically) related to multiclass MCC; for most practical purposes, MCC captures the discriminant power of CEN in a simpler, interpretable form [1008.2908].

A limitation of MCC is that it is undefined when any sum in the denominator is zero—that is, if a class is never predicted or never appears [2003.01182]. In multiclass or highly imbalanced regimes, care must be taken with such edge cases.

---

**References:**
- "Matthews Correlation Coefficient Loss for Deep Convolutional Networks: Application to Skin Lesion Segmentation" [2010.13454]
- "Assessing Software Defection Prediction Performance: Why Using the Matthews Correlation Coefficient Matters" [2003.01182]
- "The MCC approaches the geometric mean of precision and recall as true negatives approach infinity" [2305.00594]
- "Analysis and Comparison of Classification Metrics" [2209.05355]
- "The MCC-F1 curve: a performance evaluation technique for binary classification" [2006.11278]
- "Evaluating MCC for Low-Frequency Cyberattack Detection in Imbalanced Intrusion Detection Data" [2512.19203]
- "A study on cost behaviors of binary classification measures in class-imbalanced problems" [1403.7100]
- "Pearson-Matthews correlation coefficients for binary and multinary classification and hypothesis testing" [2305.05974]
- "A unifying view for performance measures in multi-class prediction" [1008.2908]
- "Weighted MCC: A Robust Measure of Multiclass Classifier Performance for Observations with Individual Weights" [2512.20811]
- "Asymptotic Properties of Matthews Correlation Coefficient" [2405.12622]
- "Statistical Inference of the Matthews Correlation Coefficient for Multiclass Classification" [2503.06450]
- "Goodness of Fit Metrics for Multi-class Predictor" [2208.05651]
- "Robust performance metrics for imbalanced classification problems" [2404.07661]

Source: https://www.emergentmind.com/topics/matthews-correlation-coefficient-mcc