How Do I Find the Matthews Correlation Coefficient (MCC) in Python?
Taken form the Matthews Correlation Coefficient documentation in sklearn:


  The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes into account true and false positives and negatives and is generally regarded as a balanced measure which can be used even if the classes are of very different sizes. The MCC is in essence a correlation coefficient value between -1 and +1. A coefficient of +1 represents a perfect prediction, 0 an average random prediction and -1 an inverse prediction. The statistic is also known as the phi coefficient.


So it's important to have the actual targets and the prediction values in the range of: -1 and +1. With this in mind you can simply run the following code:

&gt; from sklearn.metrics import matthews_corrcoef
&gt; y_true = [+1, +1, +1, -1]
&gt; y_pred = [+1, -1, +1, +1]
&gt; matthews_corrcoef(y_true, y_pred)  

-0.33...


For more details about the formula refer to the Wikipedia page of Matthews Correlation Coefficient