Can anyone help me make the top row of the confusion matrix not be cut in half. I am graphing a classification of 21 classes and my code is here:
def plot_confusion_matrix(y_true,y_predicted):
cm = metrics.confusion_matrix(y_true, y_predicted)
cm = list((cm.T / cm.astype(np.float).sum(axis=1)).T)
#rounding the numbers to only 2 decimal places
for y in range(0, 21):
for x in range(0, 21):
cm[x][y] = round(cm[x][y], 2)
print ("Plotting the Confusion Matrix")
labels = list(label_map.values())
df_cm = pd.DataFrame(cm,index = labels,columns = labels)
fig = plt.figure()
res = sns.heatmap(df_cm, annot=True,cmap='Blues', fmt='g')
plt.yticks([0.5,1.5,2.5,3.5,4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5], labels,va='center')
plt.ylabel('True label')
plt.xlabel('Predicted label')
plt.show()
plt.close()
plot_confusion_matrix(y_test, rf_preds)