From fb88fa67e4b1103bccd0c92c95b39e00863021ed Mon Sep 17 00:00:00 2001 From: gestures6 Date: Sat, 11 Jul 2026 09:23:45 +0300 Subject: [PATCH] save to files --- fullplot_stats.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fullplot_stats.py b/fullplot_stats.py index 657cf64..def2990 100644 --- a/fullplot_stats.py +++ b/fullplot_stats.py @@ -5,7 +5,7 @@ import matplotlib.pyplot as plt import numpy as np -def total_boxplot(DATA, creator = 'any', tester = 'any', simulation = "dummy simulation"): +def total_boxplot(DATA, creator = 'any', tester = 'any', simulation = "dummy_simulation", savepath = "./"): fig, ax = plt.subplots() @@ -59,8 +59,10 @@ def total_boxplot(DATA, creator = 'any', tester = 'any', simulation = "dummy sim ax.set(xlabel=xlabel, ylabel='Score') ax.set_title(title) + ax.figure.savefig(f'{savepath}/{creator}_{tester}_{simulation}.png', bbox_inches='tight') -def heat_map(DATA, criteria = np.median): + +def heat_map(DATA, criteria = np.median, savepath = "./"): names_to_nums = {name: num for num, name in enumerate(list(DATA.keys()))} values = np.zeros( (len(names_to_nums)+1, len(names_to_nums)+1) ) @@ -94,7 +96,9 @@ def heat_map(DATA, criteria = np.median): ax.set_yticks(range(len(DATA.keys())+1), labels=list(DATA.keys())+['mean'] ) ax.set(xlabel='tester', ylabel='creator') - ax.set_title("Cross-validation heatmap") + ax.set_title(f"Cross-validation heatmap ({criteria.__name__})") + + ax.figure.savefig(f"{savepath}/cross_validation_{criteria.__name__}.png") def convert_score(data): @@ -150,15 +154,15 @@ if __name__ == '__main__': #for cr, data in DATA.items(): #print(f"{cr}: {data}") - - total_boxplot(DATA, creator = 'any', tester = 'any') + savepath = global_path + total_boxplot(DATA, creator = 'any', tester = 'any', savepath = savepath) for name in DATA.keys(): - total_boxplot(DATA, creator = name, tester = 'any') - total_boxplot(DATA, creator = 'any', tester = name) + total_boxplot(DATA, creator = name, tester = 'any', savepath = savepath) + total_boxplot(DATA, creator = 'any', tester = name, savepath = savepath) - heat_map(DATA) + heat_map(DATA, savepath = savepath) plt.show()