-2

I create a Model and got an error like this:

Previously I changed Confusin_matrix_plot to ConfusinMatrixDisplay but instead got the error above.

Ajeet Verma
  • 2,938
  • 3
  • 13
  • 24
  • [Please don't post code, exceptions, or results as images](https://meta.stackoverflow.com/questions/285551). They can't be copied (partly) for answering and their "text" won't appear in search engines. – Gert Arnold Apr 13 '23 at 20:43

1 Answers1

0

You need to pass the output of confusion_matrix function as input to the ConfusinMatrixDisplay. Example -

import matplotlib.pyplot as plt
from sklearn.datasets import make_classification
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
X, y = make_classification(random_state=0)
X_train, X_test, y_train, y_test = train_test_split(X, y,
                                                    random_state=0)
clf = SVC(random_state=0)
clf.fit(X_train, y_train)

predictions = clf.predict(X_test)
cm = confusion_matrix(y_test, predictions, labels=clf.classes_)
disp = ConfusionMatrixDisplay(confusion_matrix=cm,
                              display_labels=clf.classes_)
disp.plot()

plt.show()

source

nithish08
  • 468
  • 2
  • 7