0
$\begingroup$

I want to calculate MCC, I have two CSV files: result.csv and true.csv

result.csv format:

                   id | prob_class1 | prob_class2 | prob_class3 | prob_class4
                    1 |0.34         | 0.4         | 0.32        |0.77
                    2 |0.84         | 0.4         | 0.2         |0.7

true.csv format:

                     id | prob_class1 | prob_class2 | prob_class3 | prob_class4
                     1 |0            | 0           | 1           |0
                     2 |0            | 1           | 0           |0
                     3 |0            | 0           | 0           |1

result.csv is the output of the multi-classification problem, true.csv is the true result. How I can calculate the Matthews Correlation Coefficient?

$\endgroup$
0
$\begingroup$

Here are the high-level steps:

  1. Load the .csv from disk into an array in memory.
  2. Threshold the probabilities to convert them to predicted target values.
  3. Call sklearn.metrics.matthews_corrcoef.
| improve this answer | |
$\endgroup$
0
$\begingroup$
from sklearn.metrics import matthews_corrcoef
y_true = [+1, +1, +1, -1]
y_pred = [+1, -1, +1, +1]
matthews_corrcoef(y_true, y_pred)

Source:

https://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.