Free Matthews Correlation Coefficient Calculator
Understanding the Matthews Correlation Coefficient
Evaluating the performance of a binary classification model demands a metric that captures both types of correct predictions and both types of errors. The Matthews correlation coefficient (MCC) does exactly that by combining true positives (TP), false positives (FP), true negatives (TN), and false negatives (FN) into a single figure. This tool applies the MCC formula automatically, giving you an immediate, balanced view of classification quality—no matter whether you work in machine learning, medical diagnostics, or quality assurance.
What the MCC Quantifies
The correlation coefficient Matthews proposed ranges from to , which is the same scale used by Pearson and other correlation measures. On this scale:
- represents a perfect agreement between prediction and ground truth.
- indicates that the classifier performs no better than a random guess.
- signifies complete disagreement—every positive is predicted negative and vice versa.
Because the MCC is symmetric and accounts for all four cells of the confusion matrix, it remains informative even when the classes are highly imbalanced—a situation where metrics like accuracy can be misleading.
The Confusion Matrix and the Matthews Correlation Formula
Before applying the Matthews correlation formula, you need to organize your results in a confusion matrix:
| Actual \ Prediction | Predicted Positive | Predicted Negative |
|---|---|---|
| Actually Positive | TP | FN |
| Actually Negative | FP | TN |
The formula that turns these four numbers into a single coefficient is:
If any of the sums in the denominator is zero, the coefficient becomes undefined because the denominator equals zero. This happens when, for example, the model never predicted a certain class.
Complementary Metrics for a Full Picture
Many researchers pair the MCC binary classification score with additional metrics, all derived from the same confusion matrix:
-
Sensitivity (Recall / True Positive Rate) – the fraction of actual positives that were correctly identified.
-
Specificity (True Negative Rate) – the fraction of actual negatives that were correctly identified.
-
Precision (Positive Predictive Value) – the proportion of predicted positives that are true positives.
-
Accuracy – the overall proportion of correct predictions.
-
F1 Score – the harmonic mean of precision and recall.
Choosing the “best” metric depends on your specific problem. For example, in a medical screening you want high sensitivity to avoid missing sick patients, while in spam detection high precision is crucial to avoid blocking legitimate emails. The MCC, however, is often regarded as the most informative single metric because it uses all four entries of the confusion matrix and works well with imbalanced datasets.
Worked Example: Ceramic Plate Inspection
Consider a quality‑control scenario where you check ceramic plates for defects. Out of 100 plates, your inspection labels 15 as defective, but the true inspection shows 25 defective plates. The confusion matrix becomes:
| Predicted Defective | Predicted Not Defective | |
|---|---|---|
| Actually Defective | 10 (TP) | 15 (FN) |
| Actually Not Defective | 5 (FP) | 70 (TN) |
Enter these values into the MCC calculator:
An MCC of roughly 0.40 indicates a moderate correlation. Looking at sensitivity:
This reveals that only 40 % of the actual defects were caught—a performance that would likely require improvement in a real factory setting.
Using the Calculator
To obtain your own result, simply enter the four confusion‑matrix counts (TP, FP, TN, FN) into the MCC calculator. The tool immediately displays the MCC value, and by opening the advanced section you also get the complementary metrics (sensitivity, specificity, precision, accuracy, F1 score). This side‑by‑side comparison helps you determine which aspects of your binary classifier are strong and where adjustments might be needed.
Whether you are training a machine‑learning model, validating a diagnostic test, or running a quality‑control check, this binary classification metric calculator gives you a trustworthy, all‑in‑one performance summary.
FAQ
1. What is the Matthews correlation coefficient used for?
The MCC is used to evaluate binary classification models by combining true positives, false positives, true negatives, and false negatives into a single balanced coefficient between -1 and +1. It is especially useful in machine learning, medical diagnostics, and quality control.
2. How is MCC different from accuracy or F1 score?
Accuracy and F1 score can be misleading when classes are imbalanced because they ignore one or two cells of the confusion matrix. The MCC uses all four cells, making it a more reliable measure even when the dataset has unequal numbers of positive and negative samples.
3. What does an MCC of 0 signify?
An MCC of 0 indicates that the prediction has no correlation with the actual outcomes—it performs no better than random chance.
4. Can I also calculate sensitivity and specificity using this calculator?
Yes. The advanced section of the calculator provides sensitivity (TP/(TP+FN)), specificity (TN/(TN+FP)), precision, accuracy, and F1 score, all derived from the same confusion matrix you enter.
5. What does it mean if the MCC formula produces an undefined result?
The denominator of the MCC formula is sqrt((TP+FP)(TP+FN)(TN+FP)(TN+FN)). If any of those sums is zero, the denominator becomes zero and the coefficient is undefined. This typically occurs when a row or column of the confusion matrix contains only zeros.
How to Use
- Enter the number of True Positives (TP) - correctly predicted positive cases.
- Fill in the False Positives (FP), True Negatives (TN), and False Negatives (FN) values.
- View the Matthews Correlation Coefficient instantly, or enable advanced metrics for additional classification statistics.