2

I am using the following code snippet for plotting confusion matrix using sklearn lib.

from sklearn.metrics import confusion_matrix,ConfusionMatrixDisplay   
cm=confusion_matrix(y_test,y_pred,normalize='true')
        
disp=ConfusionMatrixDisplay(confusion_matrix=cm,display_labels=['anger','bordome','disgust','fear', 'happiness','sadness' ,'neutral'])

and the result is given below: enter image description here

1 Answers1

2

Try adding this in your code disp.plot(xticks_rotation = 'vertical')

By default, it is displayed horizontally but this behavior can be changed.

You can find more details in the official documentation https://scikit-learn.org/stable/modules/generated/sklearn.metrics.ConfusionMatrixDisplay.html#sklearn.metrics.ConfusionMatrixDisplay