Matthews Correlation Coefficient

easy
Unit 2 · Metrics0/3 to milestone

Accuracy is misleading on imbalanced data. MCC uses all four confusion-matrix cells:

MCC=TP⋅TN−FP⋅FN(TP+FP)(TP+FN)(TN+FP)(TN+FN)\text{MCC} = \frac{TP\cdot TN - FP\cdot FN}{\sqrt{(TP+FP)(TP+FN)(TN+FP)(TN+FN)}}

Implement mcc(y_true, y_pred) for binary 0/1 labels. If any factor in the denominator is 0, return 0.0.

#metrics#classification#imbalance2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Matthews Correlation Coefficient · TechGradify