Matthews Correlation Coefficient Calculator

Evaluate a binary classifier from its confusion matrix with MCC, accuracy, precision, recall, and specificity.

Calculate Matthews correlation
Enter the four nonnegative whole-number counts from a binary confusion matrix.

About the Matthews correlation coefficient

The Matthews correlation coefficient, abbreviated MCC, is a single-score summary of binary classification performance. It combines every cell of the confusion matrix: true positives, true negatives, false positives, and false negatives. Unlike accuracy, the score remains informative when one class is much more common than the other, which makes it valuable for fraud detection, medical screening, anomaly detection, and other imbalanced problems. MCC ranges from negative one to positive one. A value of positive one indicates perfect classification, zero indicates performance with no net correlation between predictions and outcomes, and negative one indicates complete disagreement in which predictions are systematically reversed. Intermediate values should be interpreted with the costs of errors, class balance, and the operating threshold in mind rather than through a universal quality label. The numerator is true positives times true negatives minus false positives times false negatives. The denominator is the square root of four marginal totals multiplied together: predicted positives, actual positives, actual negatives, and predicted negatives. This structure makes MCC equivalent to a Pearson correlation between the observed and predicted binary labels. If any required marginal total is zero, the mathematical denominator is zero and the coefficient is undefined. The calculator also reports familiar supporting metrics. Accuracy is the proportion of all cases classified correctly. Precision is the proportion of positive predictions that are true positives. Recall, also called sensitivity, is the proportion of actual positives detected. Specificity is the proportion of actual negatives correctly rejected. These measures answer different questions, so reviewing them alongside MCC reveals whether apparently solid aggregate performance hides a weak class-specific result. Always build the confusion matrix using a clearly defined positive class and a fixed classification threshold. Reversing the positive and negative labels changes precision, recall, and specificity, although MCC itself remains consistent under simultaneous relabeling. Counts should come from data not used to fit the model, preferably a representative test set or properly constructed cross-validation predictions. MCC is especially helpful when comparing candidate classifiers across the same evaluation sample, but uncertainty still matters. A small test set can produce an unstable score, and distribution shifts can invalidate historical performance. Use this result with confidence intervals, subgroup checks, calibration analysis, and the real-world consequences of false positives and false negatives before selecting or deploying a model.

MCC examples

These confusion matrices illustrate perfect, useful, and reversed classifiers.

Confusion MatrixMCCInterpretation
TP 50, TN 50, FP 0, FN 01.000000Every case is classified correctly.
TP 90, TN 80, FP 10, FN 200.703526Both classes are handled well, with some missed positives and false alarms.
TP 0, TN 0, FP 50, FN 50-1.000000Every prediction is the opposite of the true class.

How to calculate MCC

  1. Identify which outcome is the positive class and construct a confusion matrix from evaluation predictions.
  2. Enter the true-positive, true-negative, false-positive, and false-negative counts.
  3. Select Calculate MCC to compute the coefficient and supporting performance percentages.
  4. Compare MCC with precision, recall, specificity, class prevalence, and the practical cost of each error.

Matthews correlation FAQ

Why use MCC instead of accuracy?

Accuracy can look high when a majority class dominates the sample. MCC incorporates all four confusion-matrix cells and penalizes one-sided predictions.

What does a negative MCC mean?

It means predictions are inversely associated with the true labels. A strongly negative classifier may improve if every prediction is reversed, but its pipeline should first be investigated.

Can MCC be undefined?

Yes, its denominator is zero when a required prediction or outcome marginal is empty. The calculator reports this rather than inventing a misleading score.

Is MCC suitable for multiclass models?

This calculator implements the standard binary formula. Generalized multiclass MCC definitions exist, but they require the full multiclass confusion matrix.

Does MCC choose a classification threshold?

No, it evaluates counts produced at the threshold you selected. Compare results over relevant thresholds and choose one based on validation data and error costs.