本文介绍了混淆矩阵不支持Multilabel-indicator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

multilabel-indicator is not supported是我在尝试运行时收到的错误消息:

multilabel-indicator is not supported is the error message I get, when trying to run:

confusion_matrix(y_test, predictions)

y_test是形状为DataFrameDataFrame

Horse | Dog | Cat
1       0     0
0       1     0
0       1     0
...     ...   ...

predictionsnumpy array:

[[1, 0, 0],
 [0, 1, 0],
 [0, 1, 0]]

我已经搜索了一些错误消息,但还没有真正找到可以应用的内容.有提示吗?

I've searched a bit for the error message, but haven't really found something I could apply. Any hints?

推荐答案

否,您对 confusion_matrix 必须是预测列表,而不是OHE(一种热编码).呼叫y_testy_pred上的argmax,您应该会得到期望的结果.

No, your input to confusion_matrix must be a list of predictions, not OHEs (one hot encodings). Call argmax on your y_test and y_pred, and you should get what you expect.

confusion_matrix(
    y_test.values.argmax(axis=1), predictions.argmax(axis=1))

array([[1, 0],
       [0, 2]])

这篇关于混淆矩阵不支持Multilabel-indicator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 19:47