Created
June 14, 2024 14:57
-
-
Save simonespa/4237d415d17774b745c298f0b429114a to your computer and use it in GitHub Desktop.
Confusion Matrix with Seaborn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import confusion_matrix | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
cm = confusion_matrix(y_test, y_pred) | |
plt.figure(figsize=(12,12)) | |
sns.heatmap(data=cm, # Data to plot | |
square=True, # Make the cells square, looks nicer. | |
cmap='Reds', # Colour scheme to use | |
xticklabels=model.classes_, # Labels for axis | |
yticklabels=model.classes_, # Labels for axis | |
annot=True, # add numbers to cells | |
fmt='g'); # format cell numbers as int |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment