X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=3) from sklearn import metrics cm = metrics.confusion_matrix(y_test, y_pred) disp = metrics.ConfusionMatrixDisplay(cm) disp.plot()