From ee1733839ea34ddf86247946513c9852e7aea8bb Mon Sep 17 00:00:00 2001 From: adityaagg7 <79642133+adityaagg7@users.noreply.github.com> Date: Sun, 1 Jan 2023 23:31:40 +0530 Subject: [PATCH] feat: Added Customizable plot Title removed hard coded plot title and added parameter for user input of figure titles. --- .DS_Store | Bin 0 -> 6148 bytes .../pretty_confusion_matrix.py | 7 +++++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..92ec9b3daa6d47635226aa374e0a668b654db630 GIT binary patch literal 6148 zcmeHK%}N6?5T4XMRD0=7L6E(86^mzKE$hW=4}u`If3`x`E&YLdTYLiXExZW6fuIlK zS?~=!_)QY)#%-(hAR;qM@+Fy>Wae8o*$|N`kD4W-A`#_L7`+u#Q-t+gGLo|+?5uc> zZo5=z#8EF}DFecQFz^={&>uc+QJce?%|3}rA1?^QA9oJqCIfdr`+u{n{*sI4~LsJj?7$9{1MMQJ0~vkIj&X2 z(?>i*JQq}@2E}wvr!=AgSmJgSG1s8&qd#_|_MaA?A)V9l_4YeAcTDcHxi7+6dULIY986=+rJvNsf^SI7LmHYXJrlv)@N23!V~Ot;AA|NiXzzw0DDVL%x8R}3gG ztb}ExWY5-2a(veMC?_Z^Y?m0+E~xBrtQ&k3uc2sx&gTX&u$UOc2tStsc>n+a literal 0 HcmV?d00001 diff --git a/pretty_confusion_matrix/pretty_confusion_matrix.py b/pretty_confusion_matrix/pretty_confusion_matrix.py index 5993172..a99ac74 100644 --- a/pretty_confusion_matrix/pretty_confusion_matrix.py +++ b/pretty_confusion_matrix/pretty_confusion_matrix.py @@ -152,6 +152,7 @@ def pp_matrix( figsize=[8, 8], show_null_values=0, pred_val_axis="y", + title='Confusion Matrix', ): """ print conf matrix with default layout (like matlab) @@ -234,7 +235,7 @@ def pp_matrix( ax.text(item["x"], item["y"], item["text"], **item["kw"]) # titles and legends - ax.set_title("Confusion matrix") + ax.set_title(title) ax.set_xlabel(xlbl) ax.set_ylabel(ylbl) plt.tight_layout() # set layout slim @@ -254,6 +255,7 @@ def pp_matrix_from_data( figsize=[8, 8], show_null_values=0, pred_val_axis="lin", + title="Confusion Matrix", ): """ plot confusion matrix function with y_test (actual values) and predictions (predic), @@ -268,7 +270,7 @@ def pp_matrix_from_data( columns = [ "class %s" % (i) - for i in list(ascii_uppercase)[0 : len(np.unique(y_test))] + for i in list(ascii_uppercase)[0: len(np.unique(y_test))] ] confm = confusion_matrix(y_test, predictions) @@ -280,4 +282,5 @@ def pp_matrix_from_data( figsize=figsize, show_null_values=show_null_values, pred_val_axis=pred_val_axis, + title=title, )