From 1cd1ab62a3b9536f2bb59208e3878e5d31205cf1 Mon Sep 17 00:00:00 2001 From: Manos Katsomallos Date: Wed, 29 Sep 2021 19:57:19 +0200 Subject: [PATCH] code: Ready to test with HUE dataset --- code/expt/bgt_cmp_hue.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/code/expt/bgt_cmp_hue.py b/code/expt/bgt_cmp_hue.py index 63714d2..42936e2 100644 --- a/code/expt/bgt_cmp_hue.py +++ b/code/expt/bgt_cmp_hue.py @@ -18,14 +18,12 @@ def main(args): res_file = '/home/manos/Cloud/Data/HUE/Results.zip' # User's consumption seq = lmdk_lib.load_data(args, 'cons') - # Contacts for landmark's percentages for all users - lmdk_data = lmdk_lib.load_data(args, 'usrs_expt') # The name of the dataset d = 'HUE' # The landmarks percentages lmdks_pct = [0, 20, 40, 60, 80, 100] # Landmarks' thresholds - lmdks_th = [10.0, .3, .23, .15, .13, 0] + lmdks_th = [0, .13, .15, .23, .3, 10] # The privacy budget epsilon = 1.0 @@ -48,7 +46,7 @@ def main(args): # The y axis plt.ylabel('Mean absolute error') # Set y axis label. # plt.yscale('log') - plt.ylim(0, 1.4) + plt.ylim(1, 7000) # Bar offset x_offset = -(bar_width/2)*(n - 1) @@ -60,33 +58,33 @@ def main(args): for i, pct in enumerate(lmdks_pct): # Find landmarks - lmdks = lmdk_lib.find_lmdks_cont(lmdk_data, seq, uid, pct) + lmdks = seq[seq[:, 1] < lmdks_th[i]] for _ in range(args.iter): # Skip - rls_data_s, bgts_s = lmdk_bgt.skip_cont(seq, lmdks, epsilon) + rls_data_s, bgts_s = lmdk_bgt.skip_cons(seq, lmdks, epsilon) # lmdk_bgt.validate_bgts(seq, lmdks, epsilon, bgts_s) - mae_s[i] += lmdk_bgt.mae_cont(rls_data_s)/args.iter + mae_s[i] += lmdk_bgt.mae_cons(seq, rls_data_s)/args.iter # Uniform - rls_data_u, bgts_u = lmdk_bgt.uniform_cont(seq, lmdks, epsilon) + rls_data_u, bgts_u = lmdk_bgt.uniform_cons(seq, lmdks, epsilon) # lmdk_bgt.validate_bgts(seq, lmdks, epsilon, bgts_u) - mae_u[i] += lmdk_bgt.mae_cont(rls_data_u)/args.iter + mae_u[i] += lmdk_bgt.mae_cons(seq, rls_data_u)/args.iter - # Adaptive - rls_data_a, _, _ = lmdk_bgt.adaptive_cont(seq, lmdks, epsilon, .5, .5) - mae_a[i] += lmdk_bgt.mae_cont(rls_data_a)/args.iter + # # Adaptive + rls_data_a, _, _ = lmdk_bgt.adaptive_cons(seq, lmdks, epsilon, .5, .5) + mae_a[i] += lmdk_bgt.mae_cons(seq, rls_data_a)/args.iter # Event # Calculate once if i == 0: - rls_data_evt, _ = lmdk_bgt.uniform_cont(seq, lmdk_lib.find_lmdks_cont(lmdk_data, seq, uid, 0), epsilon) - mae_evt[i] += lmdk_bgt.mae_cont(rls_data_evt)/args.iter + rls_data_evt, _ = lmdk_bgt.uniform_cons(seq, seq[seq[:, 1] < lmdks_th[0]], epsilon) + mae_evt[i] += lmdk_bgt.mae_cons(seq, rls_data_evt)/args.iter # User # Calculate once if i == 0: - rls_data_usr, _ = lmdk_bgt.uniform_cont(seq, lmdk_lib.find_lmdks_cont(lmdk_data, seq, uid, 100), epsilon) - mae_usr[i] += lmdk_bgt.mae_cont(rls_data_usr)/args.iter + rls_data_usr, _ = lmdk_bgt.uniform_cons(seq, seq[seq[:, 1] < lmdks_th[len(lmdks_th)-1]], epsilon) + mae_usr[i] += lmdk_bgt.mae_cons(seq, rls_data_usr)/args.iter plt.plot( x_i, @@ -130,7 +128,7 @@ def main(args): path = str('../../rslt/bgt_cmp/' + d) # Plot legend lmdk_lib.plot_legend() - # # Show plot + # Show plot # plt.show() # Save plot lmdk_lib.save_plot(path + '.pdf')