Last active
February 14, 2022 12:32
-
-
Save nsorros/12681d3d50f0853a22c7ca8f4cf05b68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multilabel_confusion_matrix(Y_test, Y_pred): | |
tp = Y_test.multiply(Y_pred).sum(axis=0) | |
fp = Y_pred.sum(axis=0) - tp | |
fn = Y_test.sum(axis=0) - tp | |
tn = Y_test.shape[0] - tp - fp - fn | |
return np.array([tn, fp, fn, tp]).T.reshape(-1, 2, 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment