多标签分类混淆矩阵缺少一个标签

时间:2018-08-13 18:41:37

标签: scikit-learn confusion-matrix multilabel-classification

在我的多标签分类(6个标签)中,预测结果和真实标签如下:

y_pred
array([[0., 0., 0., 0., 0., 0.],
   [0., 0., 0., 0., 0., 0.],
   [0., 0., 0., 0., 0., 0.],
   ...,
   [0., 0., 0., 0., 0., 0.],
   [0., 0., 0., 0., 0., 0.],
   [0., 0., 0., 0., 0., 0.]], dtype=float32)


y_test
array([[0, 0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0, 0],
   ...,
   [0, 0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0, 0]])

我在此post中使用

from sklearn.metrics import confusion_matrix 
confusion_matrix(y_test.argmax(axis=1), y_pred.argmax(axis=1) )

我困惑的矩阵丢失了一个标签,如下所示,只有5个标签:

array([[31635,    51,     2,    22,    18],
   [   88,     2,     0,     1,     0],
   [    7,     0,     0,     0,     0],
   [   76,     2,     0,     0,     1],
   [    9,     0,     0,     0,     1]])

希望有人知道它发生的原因。干杯。

0 个答案:

没有答案
相关问题