### Introduction

In more recent machine learning benchmark tests, such as Linguistic Acceptability, I started to see Matthews Correlation Coefficient (MCC), instead of more traditional accuracy or F1 score, being used as an evaluation metric. This Matthews Correlation Coefficient sounds familiar to me because previously I studied crystallography and there is a “Matthews Coefficient (Probabilities)” in crystallography which estimates probabilities for the occurrence of (protein) multimerization states in crystal. So I was very curious to see whether the two Matthews are the same person, what the correlations between Matthews Correlation Coefficient and Matthews Coefficient is, why a correlation coefficient would be used as a classification metric, and how Matthews Correlation Coefficient was derived. Unfortunately, Wikipedia hardly mentioned any of these.

In this blog post, I am going to present my shallow archaeological investigation on Matthews Correlation Coefficient.

### Confusion Matrix

Matthews Correlation Coefficient is computed entirely based on confusion matrix. It is necessary to understand the confusion matrix before we talk about Matthews Correlation Coefficient.

This is the confusion matrix for binary classifications. I will also restrict the discussion of the topic in this blog post to binary classifications.

$\boldsymbol{S}$ | |||
---|---|---|---|

$0$ | $1$ | ||

$\boldsymbol{P}$ | $0$ | $TN$ | $FN$ |

$1$ | $FP$ | $TP$ |

Where $\boldsymbol{S}$ is the label of the data, and $\boldsymbol{P}$ is the prediction of the data. $TN$ is “True Positives”, $FN$ is “False Negatives”, $FP$ is “False Positives”, and $TP$ is “True Positives”.

### Definition of Matthews Correlation Coefficient

On Wikipedia, it sounds like that this magic correlation coefficient was invented by Brian Matthews in the paper “Comparison of the predicted and observed secondary structure of T4 phage lysozyme” published in 1975.

The original form of the expression revised from the paper, as described on Wikipedia, are

### Derivation of Matthews Correlation Coefficient

Wikipedia never mentioned anything about how this coefficient was derived and why this expression is called as a “correlation coefficient”. So I looked into the paper.

In the paper, the author said the (Matthews) correlation coefficient was a special case for this correlation coefficient given by a book “Statistical Methods for Research Workers” authored by Ronald Fisher.

Where $S_n$ is the observation value (label) for sample $n$, $P_n$ is the predicted value (prediction) for sample $n$, $\bar{S}$ and $\bar{P}$ are the mean values of $S_n$ and $P_n$, respectively.

Wait, does this correlation coefficient look familiar? I immediately realized that it is Pearson Correlation Coefficient, which is a measure of the linear correlation between two variables $X$ and $Y$! The Pearson Correlation Coefficient was developed in the 1800s which was way before Matthews Correlation Coefficient was born!

As a special case for Pearson Correlation Coefficient, in Matthews Correlation Coefficient, $S_n$ and $P_n$ could only be binary values $0$ and $1$, which is typical for classification problems. With this assumption, we could derive the original form of the Matthews Correlation Coefficient.

It might be a little bit brain-twisting, but we have the following facts from definition or slight math tricks.

We used the above facts to further derive the numerator and denominator.

For numerator,

For denominator,

Similarly, we could derive

Thus, the whole denominator is

Taken together, we have

### Anecdote

It turns out that Brian Matthews is the author for both “Matthews Correlation Coefficient” and “Matthews Coefficient (Probabilities)”. However, the physical meanings for these two are entirely different. People who do not study crystallography would probably never hear or use Matthews Coefficient (Probabilities).

### Conclusion

Matthews Correlation Coefficient is nothing special but applying Pearson Correlation Coefficient to binary classification problems where two random variables are prediction and label. That is to say, Matthews Correlation Coefficient is a discrete case for Pearson Correlation Coefficient.

When Pearson Correlation Coefficient or Matthews Correlation Coefficient is more close to 1.0, this means that more predictions match labels; When Pearson Correlation Coefficient is more close to -1.0, this means that more predictions disagree with labels; When Pearson Correlation Coefficient is more close to 0, this means that more predictions and labels do not have strong correlations, i.e., the predictions seem to be random.

### Final Remarks

I am very surprised that after so many years Pearson Correlation Coefficient was published, Pearson Correlation Coefficient was not used for binary classification problems until Brian Matthews’s work. If there are people who used Pearson Correlation Coefficient for binary classification problems, probably Matthews Correlation Coefficient has to change names.

### References

- Comparison of the predicted and observed secondary structure of T4 phage lysozyme
- Solvent content of protein crystals