diff --git a/modules/util/plot_cm.py b/modules/util/plot_cm.py index c821cee3d6b6612ada98b997cca309f307118709..eafcb4c6b4b3fd1cdfc5f7f61fd395a704df5e49 100644 --- a/modules/util/plot_cm.py +++ b/modules/util/plot_cm.py @@ -1,5 +1,6 @@ from textwrap import wrap import re +import os import itertools #import tfplot import matplotlib @@ -8,18 +9,18 @@ from sklearn.metrics import confusion_matrix import matplotlib.pyplot as plt -def plot_confusion_matrix_values(correct_labels, predict_labels, labels, title='Confusion matrix', tensor_name = 'MyFigure/image', normalize=False): +def plot_confusion_matrix_values(correct_labels, predict_labels, labels, title='Confusion matrix', filename='confusion_matrix', normalize=False): cm = confusion_matrix(correct_labels, predict_labels) -def plot_confusion_matrix(cm, labels, title='Confusion matrix', tensor_name = 'MyFigure/image', normalize=False): +def plot_confusion_matrix(cm, labels, title='Confusion matrix', filename = 'confusion_matrix', normalize=False): ''' Parameters: correct_labels : These are your true classification categories. predict_labels : These are you predicted classification categories labels : This is a list of labels which will be used to display the axis labels title='Confusion matrix' : Title for your matrix - tensor_name = 'MyFigure/image' : Name for the output summay tensor + filename = 'confusion_matrix' : Name for the output summay tensor Returns: summary: TensorFlow summary @@ -59,3 +60,6 @@ def plot_confusion_matrix(cm, labels, title='Confusion matrix', tensor_name = 'M for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])): ax.text(j, i, format(cm[i, j], 'd') if cm[i,j]!=0 else '.', horizontalalignment="center", fontsize=6, verticalalignment='center', color= "black") fig.set_tight_layout(True) + + ImageDirAndName = os.path.join('/Users/tomrink', filename) + fig.savefig(ImageDirAndName)