Skip to content

Instantly share code, notes, and snippets.

@mesquita
mesquita / nice_cm.py
Last active January 9, 2024 19:15
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:
@JACKHAHA363
JACKHAHA363 / render_img.py
Created October 28, 2019 20:28
Plot probability with original image for demo
import cv2
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
def _rounding(ratio, max_val):
""" Return a rounded valud from 0 to max_val - 1 """
val = int(ratio * max_val)
return min(max_val - 1, val)