关于Confusion Matrix

from sklearn.metrics import confusion_matrix
y_true = [2, 0, 2, 2, 0, 1]
y_pred = [0, 0, 2, 2, 0, 2]
print confusion_matrix(y_true, y_pred)

结果:

[[2 0 0]
[0 0 1]
[1 0 2]]

理解:

首先,程序默认按照从小到大排序。

建立坐标时,按照输出逆序建立,y轴是真值,x轴是预测值

 y轴    1   0  2

         0  0  1  

         2  0  0

x轴

原文地址:https://www.cnblogs.com/qqhfeng/p/5241983.html