A normalized confusion matrix makes it easier for the data scientist to visually interpret how the labels are being predicted. In order to construct a normalized confusion matrix, we use the following code:
import matplotlib.pyplot as pltimport scikitplot as skplt#Normalized confusion matrix for the K-NN modelprediction_labels = knn_classifier.predict(X_test)skplt.metrics.plot_confusion_matrix(y_test, prediction_labels, normalize=True)plt.show()
This results in the following normalized confusion matrix:
![](/api/v2/epubs/9781789343700/files/assets/c3c87197-7a32-4095-a4f8-7ea43559918d.png)
In the preceding plot, the predicted labels are along the ...