Confusion Matrix Display in Jupyter
- Make sure
scikit-learn
andmatplotlib
are both installed:
pip install scikit-learn matplotlib
- Import
ConfusionMatrixDisplay
andpyplot
from sklearn.metrics import ConfusionMatrixDisplay
import matplotlib.pyplot as plt
ConfusionMatrixDisplay.from_predictions(y_test, y_pred, cmap="Blues")
plt.xticks(rotation=45) # Rotate x-axis labels to 45 degrees
plt.show() # Display the plot