def plot_normalized_confusion_matrix_at_depth(self):
""" Returns a normalized confusion matrix.
:returns: normalized confusion matrix
:rtype: matplotlib figure
"""
cm = metrics.confusion_matrix(self.predictions['label'], self.y_pred)
np.set_printoptions(precision = 2)
fig = plt.figure()
cm_normalized = cm.astype('float') / cm.sum(axis = 1)[:, np.newaxis]
plt.imshow(cm_normalized, interpolation = 'nearest',
cmap = plt.cm.Blues)
plt.title("Normalized Confusion Matrix")
plt.colorbar()
tick_marks = np.arange(len(self.labels))
plt.xticks(tick_marks, self.labels, rotation = 45)
plt.yticks(tick_marks, self.labels)
plt.tight_layout()
plt.ylabel('True label')
plt.xlabel('Predicted label')
return(fig)
评论列表
文章目录