TextClassification
TextClassification copied to clipboard
Annotate Confusion Matrix plots
To increase readability, annotate confusion matrix plots using this code:
fig = plt.figure(figsize=(7, 7))
ax = fig.add_subplot(111)
ax.set_aspect(1)
res = ax.imshow(conf_mat, cmap=plt.cm.jet,
interpolation='nearest')
width = len(conf_mat)
height = len(conf_mat[0])
for x in xrange(width):
for y in xrange(height):
ax.annotate(str(conf_mat[x][y]), xy=(y, x),
horizontalalignment='center',
verticalalignment='center', color='w')
alphabet = '0123456789'
plt.xticks(range(width), alphabet[:width])
plt.yticks(range(height), alphabet[:height])