TextClassification icon indicating copy to clipboard operation
TextClassification copied to clipboard

Annotate Confusion Matrix plots

Open erfannoury opened this issue 11 years ago • 0 comments

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])

erfannoury avatar Dec 14 '14 10:12 erfannoury