Correlation Coefficient Calculator (Matthews)
Find the Matthews correlation coefficient (MCC) for a classifier.
MCC is a balanced measure of binary classification quality, even on imbalanced data.
How the Math Works
The Matthews correlation coefficient (MCC) measures the quality of binary classifier predictions by comparing predicted and actual classifications. Using the formula MCC = (TP·TN - FP·FN) ÷ √((TP+FP)(TP+FN)(TN+FP)(TN+FN)), it incorporates all four elements of the confusion matrix: true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN). The numerator captures the balance between correct predictions (TP·TN) and incorrect predictions (FP·FN), while the denominator normalizes by the geometric mean of all marginal totals. MCC ranges from -1 (perfect misclassification) through 0 (random guessing) to +1 (perfect classification), making it superior to accuracy when classes are imbalanced.
Practical Applications
To apply this calculation, first construct a 2x2 confusion matrix by comparing your classifier's predictions against ground truth labels. Count TP (correctly predicted positives), TN (correctly predicted negatives), FP (negative instances incorrectly labeled positive), and FN (positive instances incorrectly labeled negative). Input these four values into the calculator to obtain the MCC score. This metric is particularly valuable for evaluating diagnostic tests, spam filters, medical screening tools, and any binary classification problem where false positives and false negatives have different costs, allowing you to compare different models objectively.
Day-to-Day Use
In everyday life, MCC helps evaluate systems that make yes/no decisions affecting important outcomes. For instance, it can assess whether a medical screening test reliably detects disease, whether an email spam filter correctly sorts important messages, or whether a loan approval algorithm fairly distinguishes between good and bad applicants. By providing a single balanced metric, MCC helps ensure that automated decision systems aren't just accurate on average but genuinely reliable in both directions, protecting against hidden biases that might otherwise go unnoticed in real-world applications.
Worked example
TP 80, TN 85, FP 15, FN 20 → MCC ≈ 0.65.
FAQ
Why prefer MCC over accuracy?
It stays informative when classes are imbalanced.