Matthews Correlation Coefficient Calculator
Compute Matthews correlation coefficient (MCC) from confusion matrix values with sensitivity, specificity, precision, and F1 score.
What Is the Matthews Correlation Coefficient?
The Matthews Correlation Coefficient (MCC) measures the quality of binary classification predictions using a confusion matrix. Unlike accuracy alone, MCC accounts for all four outcomes: true positives, false positives, true negatives, and false negatives. It is widely used in machine learning and medical testing. See also the Correlation Coefficient Calculator.
MCC Formula
$$\text{MCC} = \frac{TP \times TN - FP \times FN}{\sqrt{(TP+FP)(TP+FN)(TN+FP)(TN+FN)}}$$
MCC ranges from -1 (complete disagreement) to +1 (perfect prediction). A value of 0 indicates random guessing.
Example: Quality Control Inspection
In a batch of 100 plates, 10 are truly defective (TP=10), 5 are falsely flagged (FP=5), 70 are correctly passed (TN=70), and 15 defects are missed (FN=15). MCC = (10 x 70 - 5 x 15) / sqrt(15 x 25 x 75 x 85) = 0.4042.
Frequently Asked Questions
Why use MCC instead of accuracy?
Accuracy can be misleading with imbalanced datasets. A classifier that always predicts the majority class may have high accuracy but poor MCC. MCC balances all four confusion matrix cells.
What is a good MCC value?
MCC above 0.5 is generally considered good. Values near 1 indicate near-perfect classification, while values near 0 suggest the model performs no better than chance.
What are sensitivity and specificity?
Sensitivity (recall) is TP / (TP + FN), measuring how well actual positives are detected. Specificity is TN / (TN + FP), measuring how well actual negatives are identified.
How is MCC different from Pearson correlation?
Pearson correlation measures linear relationships between continuous variables. MCC is designed for binary classification outcomes and uses the confusion matrix rather than continuous data pairs.