Multipath indicator not supported for confusion matrix

multilabel-indicator is not supported is the error message that I get when I try to run:

confusion_matrix(y_test, predictions)

y_testis DataFrameof the form:

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

predictionsis numpy array:

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

I was looking a bit for an error message, but actually did not find what I could apply. Any clues?

+4
source share
2 answers

No, your entry in confusion_matrixshould be a list of predictions, not OHE (one hot encoding). Call argmaxon her y_testand y_pred, and you get what you expect.

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

array([[1, 0],
       [0, 2]])
+6
source

In the matrix of confusion, it takes a label vector (not a hot encoding). You have to run

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

Source: https://habr.com/ru/post/1688214/


All Articles