I create a Model and got an error like this:
Previously I changed Confusin_matrix_plot to ConfusinMatrixDisplay but instead got the error above.
I create a Model and got an error like this:
Previously I changed Confusin_matrix_plot to ConfusinMatrixDisplay but instead got the error above.
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()