Matthews Correlation Coefficient (MCC)
When classes are imbalanced—say 1% fraud and 99% legitimate—many “good-looking” metrics can quietly lie to you. Matthews Correlation Coefficient (MCC) is popular because it rewards models that get all parts of the confusion matrix right, not just the easy majority class.
What MCC measuresMCC is a single number that summarizes a binary classifier’s confusion matrix: true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN). You can think of it as the correlation between the predicted labels and the true labels. It ranges from -1 to +1:
- +1: perfect predictions
- 0: no better than random guessing (given the class balance)
- -1: perfectly wrong (systematically flipped labels)
Its formula uses all four counts, so a model can’t score well by only predicting the majority class or by gaming precision at the expense of recall (or vice versa).
Why it matters in practiceIn spam detection, disease screening, or fraud detection, you care about both kinds of mistakes: missing positives (FN) and raising false alarms (FP). Metrics like accuracy can look high even when the model never finds a positive case; F1 ignores TN entirely. MCC stays informative in these settings because TN contributes appropriately without dominating the score.
How you’ll use itMCC is typically computed after choosing a decision threshold (e.g., 0.5 on predicted probabilities). In scikit-learn, you’ll see it as:
from sklearn.metrics import matthews_corrcoef
mcc = matthews_corrcoef(y_true, y_pred)
Matthews Correlation Coefficient (MCC) is a single-number metric for binary classification that measures the correlation between predicted and true labels using all four confusion-matrix counts (TP, TN, FP, FN). It ranges from −1 (total disagreement) through 0 (no better than chance) to +1 (perfect prediction). MCC matters because it remains informative under severe class imbalance, where accuracy and F1 can mislead.
Matthews Correlation Coefficient (MCC) is like a “fair report card” for a yes/no decision. Imagine a smoke alarm: it can be right when there’s smoke, right when there’s no smoke, or make two kinds of mistakes (false alarms and missed fires). MCC rolls all four outcomes into one score, so you don’t get fooled by a lopsided situation—like when fires are rare and an alarm that always says “no fire” looks accurate.
In AI classification (spam vs. not spam, fraud vs. not fraud), MCC is valued because it stays informative even when one class is much more common than the other.