multilabel-indicator is not supported is the error message I get, when trying to run:
confusion_matrix(y_test, predictions)
y_test is a DataFrame which is of shape:
Horse | Dog | Cat 1 0 0 0 1 0 0 1 0 ... ... ... predictions is a numpy 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?
The multilabel_confusion_matrix calculates class-wise or sample-wise multilabel confusion matrices, and in multiclass tasks, labels are binarized under a one-vs-rest way; while confusion_matrix calculates one confusion matrix for confusion between every two classes.
Plotting Confusion Matrix Using Seaborn To plot a confusion matrix, we have to create a data frame of the confusion matrix, and then we can use the heatmap() function of Seaborn to plot the confusion matrix in Python. For example, let's create a random confusion matrix and plot it using the heatmap() function.
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]])
The confusion matrix takes a vector of labels (not the one-hot encoding). You should run
confusion_matrix(y_test.values.argmax(axis=1), predictions.argmax(axis=1))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With