Skip to content

Instantly share code, notes, and snippets.

@ClementC
ClementC / print_cm.py
Last active September 5, 2017 07:08 — forked from zachguo/print_cm.py
from sklearn.metrics import confusion_matrix
def print_cm(cm, labels):
"""pretty print for confusion matrixes"""
columnwidth = max([len(x) for x in labels])
# Print header
print(" " * columnwidth, end="\t")
for label in labels:
print("%{0}s".format(columnwidth) % label, end="\t")
print()