Skip to content

Instantly share code, notes, and snippets.

@vikash512
vikash512 / print_cm.py
Last active August 1, 2018 05:55 — forked from zachguo/print_cm.py
Pretty print for sklearn confusion matrix
from sklearn.metrics import confusion_matrix
def print_cm(cm, labels, hide_zeroes=False, hide_diagonal=False, hide_threshold=None):
"""pretty print for confusion matrixes"""
columnwidth = max([len(x) for x in labels]+[5]) # 5 is value length
empty_cell = " " * columnwidth
# Print header
print " " + empty_cell,
for label in labels:
print "%{0}s".format(columnwidth) % label,
@vikash512
vikash512 / plot_confusion_matrix.png
Created July 31, 2018 12:47 — forked from hitvoice/plot_confusion_matrix.png
Generate matrix plot for confusion matrix with pretty annotations.
plot_confusion_matrix.png