1FP = confusion_matrix.sum(axis=0) - np.diag(confusion_matrix)
2FN = confusion_matrix.sum(axis=1) - np.diag(confusion_matrix)
3TP = np.diag(confusion_matrix)
4TN = confusion_matrix.values.sum() - (FP + FN + TP)
5
6# Sensitivity, hit rate, recall, or true positive rate
7TPR = TP/(TP+FN)
8# Specificity or true negative rate
9TNR = TN/(TN+FP)
10# Precision or positive predictive value
11PPV = TP/(TP+FP)
12# Negative predictive value
13NPV = TN/(TN+FN)
14# Fall out or false positive rate
15FPR = FP/(FP+TN)
16# False negative rate
17FNR = FN/(TP+FN)
18# False discovery rate
19FDR = FP/(TP+FP)
20
21# Overall accuracy
22ACC = (TP+TN)/(TP+FP+FN+TN)
23