Created
March 15, 2023 19:40
-
-
Save amitness/08cdb09e322c46995ddfc864293c17ad to your computer and use it in GitHub Desktop.
confusion matrix
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
import matplotlib.pyplot as plt | |
from sklearn.metrics import ConfusionMatrixDisplay, confusion_matrix | |
def plot_confusion_matrix(y_preds, y_true, labels): | |
cm = confusion_matrix(y_true, y_preds) | |
fig, ax = plt.subplots(figsize=(6, 6)) | |
disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=labels) | |
disp.plot(cmap="Blues", values_format=".2f", ax=ax, colorbar=False) | |
plt.title("Normalized confusion matrix") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment