Created
July 31, 2019 18:32
-
-
Save redpoint13/9d68ee86b4befe54d2a272d3cc05602a to your computer and use it in GitHub Desktop.
Formulas for confusion matrix components
This file contains hidden or 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
# True Positive (TP): we predict a label of 1 (positive), and the true label is 1. | |
TP = np.sum(np.logical_and(pred_labels == 1, true_labels == 1)) | |
# True Negative (TN): we predict a label of 0 (negative), and the true label is 0. | |
TN = np.sum(np.logical_and(pred_labels == 0, true_labels == 0)) | |
# False Positive (FP): we predict a label of 1 (positive), but the true label is 0. | |
FP = np.sum(np.logical_and(pred_labels == 1, true_labels == 0)) | |
# False Negative (FN): we predict a label of 0 (negative), but the true label is 1. | |
FN = np.sum(np.logical_and(pred_labels == 0, true_labels == 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment