Skip to content

Instantly share code, notes, and snippets.

@mesquita
mesquita / nice_cm.py
Last active July 26, 2024 13:52
Nice Confusion Matrix with percentage cbar
from matplotlib.ticker import PercentFormatter
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.metrics import confusion_matrix
def cm_analysis(y_true, y_pred, filename, labels, classes, ymap=None, figsize=(17,17)):
"""
Generate matrix plot of confusion matrix with pretty annotations.
The plot image is saved to disk.
args:
@mesquita
mesquita / set_plot_props.py
Created December 30, 2021 19:13
Set plot properties
def set_plot_props(font_size: int = 14):
"""This function sets some plot configurations for the matplotlib."""
plt.rcParams["axes.prop_cycle"] = cycler("color", plt.get_cmap("tab10").colors)
plt.rcParams["figure.dpi"] = 150
plt.rcParams["savefig.dpi"] = 300
plt.rcParams["lines.linewidth"] = 2.5
plt.rcParams["font.size"] = font_size