Math · Machine learning · MCC
Matthews correlation coefficient calculator.
Compute the Matthews correlation coefficient (MCC, also the phi coefficient) from the four confusion matrix cells, side by side with accuracy and F1 so you can see where they disagree.
For TP = 40, FP = 10, FN = 5 and TN = 45, MCC = (40×45 − 10×5) / √(50×45×55×50) = 0.7035, while accuracy is 85% and F1 is 0.842.
Inputs
Your result
Fill the form and press Calculate.
The formula
For a binary confusion matrix, MCC = (TP×TN − FP×FN) / √((TP+FP)(TP+FN)(TN+FP)(TN+FN)). scikit-learn describes it as "a correlation coefficient value between -1 and +1": +1 is a perfect prediction, 0 an average random prediction and -1 an inverse prediction. It is also known as the phi coefficient. If any of the four sums under the square root is zero the formula is undefined; scikit-learn returns 0 in that case, and so does this page (with a note).
Worked example: why MCC differs from F1
Suppose a model predicts "positive" for all 100 cases and 95 of them really are positive: TP 95, FP 5, FN 0, TN 0. Accuracy is 95%, recall 100% and F1 = 190/195 = 0.974, which looks excellent. But no case was predicted negative, so a row of the matrix sums to zero, MCC is undefined and is reported as 0: the model shows no skill on the negative class. Now compare TP 5, FP 5, FN 0, TN 90, a model that finds every positive and 90 of 95 negatives: F1 is 0.667 and MCC is 0.688.
When to use it
Chicco and Jurman (2020) argue that MCC should be preferred to accuracy and F1 for binary classification because it produces a high score only when the model does well on all four confusion matrix categories, in proportion to both class sizes. That is a published argument, not a law; F1 or recall is still the right focus when only the positive class matters. MCC is symmetric: swapping which class is called "positive" does not change it, unlike F1.
Sources, opened 15 October 2026: scikit-learn matthews_corrcoef; Chicco D, Jurman G (2020), The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy in binary classification evaluation, BMC Genomics 21:6; scikit-learn User Guide, Metrics and scoring.
Frequently asked questions
What is a good MCC value?
MCC runs from -1 to +1, where +1 is perfect, 0 is no better than random and -1 is perfectly inverted. How high is "good" depends on the task and the baseline; there is no single published cut-off.
Is MCC the same as the phi coefficient?
Yes. scikit-learn notes that the statistic is also known as the phi coefficient. For a 2×2 table they are the same number.
Why is MCC better than F1 on imbalanced data?
F1 ignores true negatives, so it can look excellent while the negative class is predicted badly. MCC uses all four cells. Chicco and Jurman (2020) recommend it over accuracy and F1 for binary evaluation.
What if the MCC denominator is zero?
If the model predicts only one class, or the data contains only one class, a row or column sum is zero. The ratio is undefined; scikit-learn returns 0 and so does this calculator, with a note.
Does MCC work for more than two classes?
There is a multiclass generalisation, which scikit-learn supports. The multiclass calculator on this site reports it from an N×N matrix.
Learning and planning aid
Results are computed in your browser from the numbers you enter and the formulas described above. Check them against your own evaluation code before relying on them in a paper or a production decision.