Confusion Matrix with number of classified/misclassified instances on it (Python/Matplotlib)

前端 未结 2 1690
离开以前
离开以前 2020-12-09 21:02

I am plotting a confusion matrix with matplotlib with the following code:

from numpy import *
import matplotlib.pyplot as plt
from pylab import *

conf_arr =         


        
2条回答
  •  半阙折子戏
    2020-12-09 21:22

    The only way I could really see of doing it was to use annotations. Try these lines:

    for i,j in ((x,y) for x in xrange(len(conf_arr))
                for y in xrange(len(conf_arr[0]))):
        ax.annotate(str(conf_arr[i][j]),xy=(i,j))
    

    before saving the figure. It adds the numbers, but I'll let you figure out how to get the sizes of the numbers how you want them.

提交回复
热议问题