Skip to content Skip to sidebar Skip to footer

Confusion Matrix Fails To Show All Labels

I have created a classification matrix for multi-label classification to evaluate the performance of the MLPClassifier model. The confusion matrix output should be 10x10 but at tim

Solution 1:

I think there is confusion here! a confusion matrix is set(y_test) + set(y_pred). so if this comes to be 8. then the matrix will be 8 X 8. Now, if you have more labels you want to print even though it does not matter if it's all zero. then while building the matrix , you need to feed "labels" parameter.

y_true = [2, 0, 2, 2, 0, 1,5]
y_pred = [0, 0, 2, 2, 0, 2,4]
confusion_matrix = confusion_matrix(y_true, y_pred,labels=[0,1,2,3,4,5,6])

as you can see, 6 is really not there in y_true or y_pred, you will zeros for it. enter image description here

Post a Comment for "Confusion Matrix Fails To Show All Labels"