小编ohd*_*nut的帖子

指定的至少一个标签必须在 y_true 中

我想根据 y_test 和 pred_test 得到一个混淆矩阵,但提出一个问题“至少指定的一个标签必须在 y_true 中”,我不知道为什么

metrics.confusion_matrix(np.argmax(y_test,axis=1),pred_test)


  y_test =  [[0. 1. 0. 0. 0. 0.]
     [0. 0. 0. 0. 0. 1.]
     [0. 0. 0. 0. 1. 0.]
     ...
     [0. 0. 0. 1. 0. 0.]
     [0. 0. 1. 0. 0. 0.]
     [0. 0. 1. 0. 0. 0.]]

   pred_test = [1 4 5 ... 3 2 2]
   np.argmax(y_test,axis=1) = [1 5 4 ... 3 2 2]

  File "D:\Anaconda\lib\site-packages\sklearn\metrics\classification.py", line 259, in confusion_matrix
    raise ValueError("At least one label specified must be in …
Run Code Online (Sandbox Code Playgroud)

python deep-learning

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

deep-learning ×1

python ×1