Matthews Correlation Coefficient
Print PageA Matthews Correlation Coefficient Calculator (also known as an MCC Calculator, Binary Classification Confusion Matrix Evaluator, Phi Coefficient [φ] Utility, or Imbalanced Dataset Model Analyzer) computes the Matthews Correlation Coefficient (MCC = [ (TP · TN) - (FP · FN) ] ÷ √[ (TP + FP)(TP + FN)(TN + FP)(TN + FN) ]), Phi coefficient (φ), F1-score (F1 = 2TP ÷ [2TP + FP + FN]), raw accuracy, balanced accuracy, precision, sensitivity (recall), and specificity.
In machine learning model validation, medical diagnostic screening, bioinformatics (protein secondary structure prediction), and fraud detection, MCC is widely recognized as the single most reliable statistical metric for binary classification because it produces a high score **only if the model performs well across all four quadrants of the confusion matrix** (True Positives, True Negatives, False Positives, and False Negatives).
Our free online Matthews Correlation Coefficient Calculator provides instant calculations across all binary confusion matrix parameters:
- Matthews Correlation Coefficient Formula (MCC):
MCC = [ ( TP · TN ) - ( FP · FN ) ] ÷ √[ ( TP + FP ) · ( TP + FN ) · ( TN + FP ) · ( TN + FN ) ]. - Phi Coefficient Equivalency (φ):
φ = MCC(For binary 2×2 contingency tables). - Interpretation Scale:
MCC = +1.00: Perfect binary prediction.MCC = 0.00: No better than random coin-toss guessing.MCC = -1.00: Total disagreement / complete inverse prediction.
- F1-Score Formula (F1):
F1 = ( 2 · TP ) ÷ ( 2 · TP + FP + FN ). - Precision / Positive Predictive Value (PPV):
Precision = TP ÷ ( TP + FP ). - Sensitivity / Recall / True Positive Rate (TPR):
Sensitivity = TP ÷ ( TP + FN ). - Specificity / True Negative Rate (TNR):
Specificity = TN ÷ ( TN + FP ). - Balanced Accuracy:
Balanced Accuracy = ( Sensitivity + Specificity ) ÷ 2.
Master MCC Reference Table (Imbalanced Medical ML Screening Model: N = 1,000 Patient Cases)
The table below displays confusion matrix quadrants (TP, TN, FP, FN), raw accuracy, F1-score, and calculated MCC values for a machine learning model evaluated on an imbalanced medical dataset (900 Healthy Controls [90%], 100 Disease Positive Cases [10%]):
| Confusion Matrix Quadrant | Patient Sample Count | Quadrant Percentage Share (%) | Calculated Classification Metric | Machine Learning Performance Evaluation |
|---|---|---|---|---|
| True Positives (TP – Correct Disease) | 80 patients | 8.0000% (8.0%) | Sensitivity = 80.00% (80/100) | 80% Disease Detection Recall Rate |
| True Negatives (TN – Correct Healthy) | 810 patients | 81.0000% (81.0%) | Specificity = 90.00% (810/900) | 90% Healthy Control Verification |
| False Positives (FP – False Alarm) | 90 patients | 9.0000% (9.0%) | Precision = 47.06% (80/170) | High False Alarm Rate (Precision < 50%) |
| False Negatives (FN – Missed Case) | 20 patients | 2.0000% (2.0%) | Miss Rate = 20.00% (20/100) | 20 Missed Clinical Positive Diagnoses |
| Raw Accuracy (Misleading Metric) | (80 + 810) / 1,000 | 890 / 1,000 | 89.0000% (89.0%) | Overly Optimistic Due to Majority Class |
| F1-Score Metric | 160 / (160 + 90 + 20) | 160 / 270 | 0.5926 (59.26%) | Ignores True Negatives (TN = 810) |
| Matthews Correlation Coefficient (MCC) | 63,000 / 11,268.98 | Correlation Coefficient | MCC = +0.5591 (0.559) | True Moderate-to-Strong Classifier Performance |
Step-by-Step Imbalanced Medical ML Model Calculation
To evaluate a machine learning model with confusion matrix TP = 80, TN = 810, FP = 90, FN = 20:
Step 1 (Calculate Raw Accuracy): Accuracy = (TP + TN) ÷ N = (80 + 810) ÷ 1,000 = 890 ÷ 1,000 = 0.8900 &implies; 89.00% (Misleadingly High!)
Step 2 (Calculate Precision & Recall): Precision = 80 ÷ (80 + 90) = 47.06%; Sensitivity = 80 ÷ (80 + 20) = 80.00%
Step 3 (Calculate F1-Score): F1 = (2 · 80) ÷ (160 + 90 + 20) = 160 ÷ 270 = 0.5926 ≈ 59.26%
Step 4 (Calculate Numerator for MCC): Numerator = (TP · TN) - (FP · FN) = (80 · 810) - (90 · 20) = 64,800 - 1,800 = 63,000
Step 5 (Calculate Denominator for MCC): Denominator = √[ (80+90) · (80+20) · (810+90) · (810+20) ] = √[ 170 · 100 · 900 · 830 ] = √126,990,000 = 11,268.983
Step 6 (Calculate MCC): MCC = 63,000 ÷ 11,268.983 = 0.55906 ≈ +0.559
Thus, while raw accuracy falsely reports 89.0%, the Matthews Correlation Coefficient (MCC = +0.559) provides the true balanced evaluation of classifier reliability.
Classifier Evaluation Metrics Comparison: MCC vs. F1-Score vs. Accuracy vs. Cohen’s Kappa
Below is a comparative reference chart detailing when to use MCC versus alternative machine learning metrics:
| Evaluation Metric | Confusion Matrix Quadrants Included | Imbalanced Dataset Reliability | Primary Practical Application |
|---|---|---|---|
| Matthews Correlation Coefficient (MCC) | ALL FOUR (TP, TN, FP, FN) | SUPERIOR (Symmetric & invariant to class swaps) | Imbalanced AI classification, genomics, fraud detection. |
| F1-Score | THREE ONLY (TP, FP, FN — Ignores TN!) | MODERATE (Changes if positive/negative classes swap) | Information retrieval & NLP text classification. |
| Raw Accuracy | TWO ONLY (TP, TN) | POOR (High accuracy on 99% majority negative class) | Strictly balanced datasets (50/50 split). |
| Cohen’s Kappa (κ) | ALL FOUR (Observed vs Expected agreement) | MODERATE (Sensitive to marginal prevalence) | Inter-rater agreement testing. |
History & Mathematics: 1975 Brian Matthews to 2020 BMC Genomics
1975 Brian W. Matthews & Protein Science
In 1975, American biochemist Brian W. Matthews introduced the coefficient in Biochimica et Biophysica Acta to evaluate algorithm performance in predicting protein secondary structures.
2020 Davide Chicco & Giuseppe Jurman (BMC Genomics)
In 2020, researchers Davide Chicco and Giuseppe Jurman published The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy in binary classification evaluation in BMC Genomics, establishing MCC as the gold-standard metric for imbalanced machine learning evaluation.
Popular direct tools:
Frequently Asked Questions (FAQ)
What is the formula for the Matthews Correlation Coefficient (MCC)?
The formula is MCC = [ (TP · TN) - (FP · FN) ] ÷ √[ (TP+FP)(TP+FN)(TN+FP)(TN+FN) ].
Why is MCC better than F1-score for imbalanced datasets?
F1-score completely ignores True Negatives (TN). A model that fails to classify healthy controls can still achieve a high F1-score. MCC requires high accuracy across all four quadrants (TP, TN, FP, FN) to return a high score.
What does an MCC of 0.0 mean?
An MCC = 0.0 means the model’s predictions are **no better than random coin-toss guessing**.