Matthews Correlation Coefficient
Description
Given the confusion-matrix counts true positives, true negatives, false positives, and false negatives, return the Matthews correlation coefficient: (TP*TN - FP*FN) / sqrt((TP+FP)(TP+FN)(TN+FP)(TN+FN)). Return 0 when the denominator is 0. Round the result to 4 decimal places.
Examples
50, 40, 5, 50.798The coefficient summarizes the full confusion matrix into a single balanced score that runs from minus one for total disagreement to plus one for perfect prediction.
10, 10, 0, 01The coefficient summarizes the full confusion matrix into a single balanced score that runs from minus one for total disagreement to plus one for perfect prediction.
5, 5, 5, 50The coefficient summarizes the full confusion matrix into a single balanced score that runs from minus one for total disagreement to plus one for perfect prediction.
Constraints
- •
0 ≤ each count - •
at least one count positive