#According to scikit-learn documentation, #http://scikit-learn.org/stable/modules/generated/sklearn.metrics.confusion_matrix.html#sklearn.metrics.confusion_matrix #By definition a confusion matrix C is such that C[i, j] is equal to the number of observations known to be in group i but predicted to be in group j. #Thus in binary classification, the count of true negatives is C[0,0], false negatives is C[1,0], true positives is C[1,1] and false positives is C[0,1]. CM = confusion_matrix(y_true, y_pred) TN = CM FN = CM TP = CM FP = CM
Here is what the above code is Doing:
1. We are creating a confusion matrix CM using the confusion_matrix function from sklearn.metrics.
2. We are then creating four variables TN, FN, TP, FP which are the four cells of the confusion matrix.