October 2017
Beginner to intermediate
270 pages
7h
English
Every classification task aims to predict a label or tag for new unknown data. A very efficient way of showing the classification's accuracy is through a confusion matrix, where we show [classified sample, ground truth] pairs and a detailed view of how the predictions are doing.
The expected output should be the main diagonal of the matrix with a 1.0 score; that is, all the expected values should match the real ones.
In the following code example, we will do a synthetic sample of predictions and real values, and generate a confusion matrix of the final data:
from sklearn.metrics import confusion_matriximport matplotlib.pyplot as pltimport numpy as npy_true = [8,5,6,8,5,3,1,6,4,2,5,3,1,4]y_pred = [8,5,6,8,5,2,3,4,4,5,5,7,2,6] ...
Read now
Unlock full access