5

when I plot my confusion matrix using this code

from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
cm = confusion_matrix(y_test, rmc_pred, labels=rmc.classes_)

disp = ConfusionMatrixDisplay(confusion_matrix=cm,
                                display_labels=rmc.classes_)


disp.plot() 

I get a matrix in the colours purple, yellow, blue and green and there are vertical and horizontal lines cutting each row. I want to get a blue coloured confusion matrix looking like in the documentation of sklearn. Could anybody of you help me with how to do so? Many thanks in advance!

If I use sklearns function plot_confusion_matrix with the cmap parameter I receive an error message stating: The number of FixedLocator locations (9), usually from a call to set_ticks, does not match the number of ticklabels (10).

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
apt1978
  • 51
  • 1
  • 3

1 Answers1

9

You can simply change the cmap used to display your confusion matrix as follows:

import matplotlib.pyplot as plt
disp.plot(cmap=plt.cm.Blues)
Antoine Dubuis
  • 4,974
  • 1
  • 15
  • 29