混淆矩阵不支持Multilabel-indicator

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

confusion_matrix(y_test, predictions)

y_testDataFrame形状如下的:

Horse | Dog | Cat

1 0 0

0 1 0

0 1 0

... ... ...

predictions是一个numpy array

[[1, 0, 0],

[0, 1, 0],

[0, 1, 0]]

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

回答:

不,您输入的内容confusion_matrix必须是预测列表,而不是OHE(一种热编码)。调用argmax您的y_testy_pred,您应该得到期望的结果。

confusion_matrix(

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

array([[1, 0],

[0, 2]])

以上是 混淆矩阵不支持Multilabel-indicator 的全部内容, 来源链接: utcz.com/qa/427194.html

回到顶部