Skip to content

Instantly share code, notes, and snippets.

@vikash512
vikash512 / print_cm.py
Last active Aug 1, 2018 — forked from zachguo/print_cm.py
Pretty print for sklearn confusion matrix
View print_cm.py
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 Jul 31, 2018 — forked from hitvoice/plot_confusion_matrix.png
Generate matrix plot for confusion matrix with pretty annotations.