Skip to content
Omnikalc

Matthews correlation coefficient calculator: a balanced score for a confusion matrix

Enter true and false positives and negatives to get the MCC, along with accuracy, the F1 score and Youden's J.

Updated on
Your inputs

Value out of range

Value out of range

Value out of range

Value out of range

Results

Matthews correlation coefficient (MCC)

0.7092

Strong agreement between predictions and reality
Accuracy
86.67 %
F1 score
0.8095
Youden's J (sensitivity + specificity − 1)
0.6938

Accuracy can mislead when one class is rare. The Matthews correlation coefficient calculator takes the true positives, false positives, false negatives and true negatives, and gives the MCC, plus the accuracy, the F1 score and Youden’s J so you can compare them.

How the calculation works

  • Enter the four cells of your confusion matrix: true positives, false positives, false negatives and true negatives.
  • The Matthews correlation coefficient is MCC = (TP × TN − FP × FN) ÷ √((TP + FP)(TP + FN)(TN + FP)(TN + FN)).
  • It ranges from −1, a perfect inverse prediction, through 0, no better than chance, to +1, a perfect prediction.
  • The calculator also shows the accuracy, the F1 score and Youden’s J for comparison.

Example

A test gives 85 true positives, 15 false positives, 25 false negatives and 175 true negatives. The numerator is 85 × 175 − 15 × 25 = 14,500 and the denominator is √(100 × 110 × 200 × 190) ≈ 20,445, so MCC = 0.7092. Accuracy is 86.67 %, the F1 score is 0.8095 and Youden’s J is 0.6938.

Why it matters

Machine learning practitioners, diagnostic test developers and bioinformaticians use MCC because it treats both classes fairly. Many publications now report it next to accuracy and F1 for binary classification, and it is especially useful when a model must be compared across datasets with very different shares of positive cases.

Good to know

MCC describes one operating point of a classifier. It does not show how performance changes with the decision threshold, which is what an ROC curve shows. For more than two classes, a multiclass version exists but is not covered here. Report the four counts along with the MCC so that readers can recompute any other metric they prefer.

The confusion matrix calculator gives more standard metrics from the same four counts, and the correlation significance calculator explains the idea behind MCC.

Frequently asked questions

What is the Matthews correlation coefficient?

It is a single number that summarizes the quality of a binary classifier using all four cells of the confusion matrix. It is the Pearson correlation between the predicted and the true labels, and it is often described as a balanced measure.

Why is MCC better than accuracy on imbalanced data?

Accuracy can look excellent if a classifier simply predicts the majority class. MCC only gives a high score if the classifier does well on both classes. When 95 percent of the cases are negative, always predicting negative gives 95 percent accuracy but an MCC of 0.

How do I read the value?

A value near 1 means predictions and reality agree almost perfectly, 0 means the prediction is no better than random guessing and −1 means that it disagrees completely. Many practitioners treat 0.7 or higher as strong, but the right threshold depends on the field.

What happens if a row or column of the matrix is empty?

If any of the four sums in the denominator is zero, the MCC is undefined. By convention, this calculator then reports 0, which signals that the score gives no information.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.