Confusion matrix

At first glance, a false positive and a false negative can be considered as similar errors, but think about a medical prediction: while a false positive can be easily discovered with further tests, a false negative is often neglected, with repercussions as a result of this. For this reason, it's useful to introduce the concept of a confusion matrix:

The standard structure of a binary confusion matrix

In scikit-learn, it's possible to build a confusion matrix using the confusion_matrix built-in function. Let's consider a generic logistic regression on dataset X with Y labels:

X_train, X_test, Y_train, Y_test = train_test_split(X, ...

Get Machine Learning Algorithms - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.