code: Ready to test with HUE dataset
This commit is contained in:
parent
2aeb1149e5
commit
1cd1ab62a3
@ -18,14 +18,12 @@ def main(args):
|
|||||||
res_file = '/home/manos/Cloud/Data/HUE/Results.zip'
|
res_file = '/home/manos/Cloud/Data/HUE/Results.zip'
|
||||||
# User's consumption
|
# User's consumption
|
||||||
seq = lmdk_lib.load_data(args, 'cons')
|
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
|
# The name of the dataset
|
||||||
d = 'HUE'
|
d = 'HUE'
|
||||||
# The landmarks percentages
|
# The landmarks percentages
|
||||||
lmdks_pct = [0, 20, 40, 60, 80, 100]
|
lmdks_pct = [0, 20, 40, 60, 80, 100]
|
||||||
# Landmarks' thresholds
|
# Landmarks' thresholds
|
||||||
lmdks_th = [10.0, .3, .23, .15, .13, 0]
|
lmdks_th = [0, .13, .15, .23, .3, 10]
|
||||||
# The privacy budget
|
# The privacy budget
|
||||||
epsilon = 1.0
|
epsilon = 1.0
|
||||||
|
|
||||||
@ -48,7 +46,7 @@ def main(args):
|
|||||||
# The y axis
|
# The y axis
|
||||||
plt.ylabel('Mean absolute error') # Set y axis label.
|
plt.ylabel('Mean absolute error') # Set y axis label.
|
||||||
# plt.yscale('log')
|
# plt.yscale('log')
|
||||||
plt.ylim(0, 1.4)
|
plt.ylim(1, 7000)
|
||||||
# Bar offset
|
# Bar offset
|
||||||
x_offset = -(bar_width/2)*(n - 1)
|
x_offset = -(bar_width/2)*(n - 1)
|
||||||
|
|
||||||
@ -60,33 +58,33 @@ def main(args):
|
|||||||
|
|
||||||
for i, pct in enumerate(lmdks_pct):
|
for i, pct in enumerate(lmdks_pct):
|
||||||
# Find landmarks
|
# 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):
|
for _ in range(args.iter):
|
||||||
# Skip
|
# 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)
|
# 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
|
# 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)
|
# 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
|
# # Adaptive
|
||||||
rls_data_a, _, _ = lmdk_bgt.adaptive_cont(seq, lmdks, epsilon, .5, .5)
|
rls_data_a, _, _ = lmdk_bgt.adaptive_cons(seq, lmdks, epsilon, .5, .5)
|
||||||
mae_a[i] += lmdk_bgt.mae_cont(rls_data_a)/args.iter
|
mae_a[i] += lmdk_bgt.mae_cons(seq, rls_data_a)/args.iter
|
||||||
|
|
||||||
# Event
|
# Event
|
||||||
# Calculate once
|
# Calculate once
|
||||||
if i == 0:
|
if i == 0:
|
||||||
rls_data_evt, _ = lmdk_bgt.uniform_cont(seq, lmdk_lib.find_lmdks_cont(lmdk_data, seq, uid, 0), epsilon)
|
rls_data_evt, _ = lmdk_bgt.uniform_cons(seq, seq[seq[:, 1] < lmdks_th[0]], epsilon)
|
||||||
mae_evt[i] += lmdk_bgt.mae_cont(rls_data_evt)/args.iter
|
mae_evt[i] += lmdk_bgt.mae_cons(seq, rls_data_evt)/args.iter
|
||||||
# User
|
# User
|
||||||
# Calculate once
|
# Calculate once
|
||||||
if i == 0:
|
if i == 0:
|
||||||
rls_data_usr, _ = lmdk_bgt.uniform_cont(seq, lmdk_lib.find_lmdks_cont(lmdk_data, seq, uid, 100), epsilon)
|
rls_data_usr, _ = lmdk_bgt.uniform_cons(seq, seq[seq[:, 1] < lmdks_th[len(lmdks_th)-1]], epsilon)
|
||||||
mae_usr[i] += lmdk_bgt.mae_cont(rls_data_usr)/args.iter
|
mae_usr[i] += lmdk_bgt.mae_cons(seq, rls_data_usr)/args.iter
|
||||||
|
|
||||||
plt.plot(
|
plt.plot(
|
||||||
x_i,
|
x_i,
|
||||||
@ -130,7 +128,7 @@ def main(args):
|
|||||||
path = str('../../rslt/bgt_cmp/' + d)
|
path = str('../../rslt/bgt_cmp/' + d)
|
||||||
# Plot legend
|
# Plot legend
|
||||||
lmdk_lib.plot_legend()
|
lmdk_lib.plot_legend()
|
||||||
# # Show plot
|
# Show plot
|
||||||
# plt.show()
|
# plt.show()
|
||||||
# Save plot
|
# Save plot
|
||||||
lmdk_lib.save_plot(path + '.pdf')
|
lmdk_lib.save_plot(path + '.pdf')
|
||||||
|
Loading…
Reference in New Issue
Block a user