sklearn.metrics.ConfusionMatrixDisplay using scientific notation

Viewed 2684

I am generating a confusion matrix as follows:

from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
cm = confusion_matrix(truth_labels, predicted_labels, labels=n_classes)
disp = ConfusionMatrixDisplay(confusion_matrix=cm)
disp = disp.plot(cmap="Blues")
plt.show()

However, some of my values for True Positive, True Negative, etc. are over 30,000, and they are being displayed in scientific format (3e+04). I want to show all digits and have found the values_format parameter in the ConfusionMatrixDisplay documentation. I have tried using it like this:

disp = ConfusionMatrixDisplay(confusion_matrix=cm, values_format='')

But I get a type error:

TypeError: __init__() got an unexpected keyword argument 'values_format'.

What I am doing wrong? Thanks in advance!

1 Answers

In case somebody runs into the same problem, I just found the answer. The values_format argument had to be added to disp.plot, not to the ConfusionMatrixDisplay call, as such:

disp.plot(cmap="Blues", values_format='')
Related