code: Experiments for sel-eps

This commit is contained in:
Manos Katsomallos 2021-10-13 09:02:09 +02:00
parent ac9d808190
commit cd4a5be7d8
3 changed files with 26 additions and 31 deletions

View File

@ -29,13 +29,13 @@ def main(args):
lmdks_pct = [0, 20, 40, 60, 80, 100]
# The privacy budget
epsilon = 1.0
eps_pct = [20, 40, 60, 80]
eps_pct = [.201, .51, .725, .95]
markers = [
'^', # 20
'v', # 40
'D', # 60
's' # 80
'^',
'v',
'D',
's'
]
print('\n##############################', d, '\n')
@ -51,7 +51,6 @@ def main(args):
plt.xlim(x_i.min(), x_i.max())
# The y axis
plt.ylabel('Mean absolute error (%)') # Set y axis label.
# plt.yscale('log')
plt.ylim(0, 100)
mae_evt = 0
@ -86,14 +85,13 @@ def main(args):
plt.plot(
x_i,
mae,
label=str(e/100) + 'ε',
label='{0:.2f}'.format(e) + 'ε',
marker=markers[i_e],
markersize=lmdk_lib.marker_size,
markeredgewidth=0,
linewidth=lmdk_lib.line_width
)
plt.axhline(
y = mae_evt,
color = '#212121',

View File

@ -27,13 +27,13 @@ def main(args):
lmdks_th = [0, .54, .68, .88, 1.12, 10]
# The privacy budget
epsilon = 1.0
eps_pct = [20, 40, 60, 80]
eps_pct = [.01, .1, .25, .5]
markers = [
'^', # 20
'v', # 40
'D', # 60
's' # 80
'^',
'v',
'D',
's'
]
print('\n##############################', d, '\n')
@ -47,8 +47,8 @@ def main(args):
plt.xlim(x_i.min(), x_i.max())
# The y axis
plt.ylabel('Mean absolute error (kWh)') # Set y axis label.
plt.yscale('log')
plt.ylim(.1, 100000)
# plt.yscale('log')
# plt.ylim(.1, 100000)
mae_evt = 0
mae_usr = 0
@ -61,11 +61,10 @@ def main(args):
lmdks = seq[seq[:, 1] < lmdks_th[i]]
for _ in range(args.iter):
lmdks = lmdk_sel.find_lmdks_eps(seq, lmdks, epsilon*e/100)
lmdks_sel = lmdk_sel.find_lmdks_eps(seq, lmdks, epsilon*e)
# Uniform
rls_data, _ = lmdk_bgt.uniform_cons(seq, lmdks, epsilon*(1 - e/100))
rls_data, _ = lmdk_bgt.uniform_cons(seq, lmdks_sel, epsilon*(1 - e))
mae[i] += lmdk_bgt.mae_cons(seq, rls_data)/args.iter
# Calculate once
@ -82,7 +81,7 @@ def main(args):
plt.plot(
x_i,
mae,
label=str(e/100) + 'ε',
label='{0:.2f}'.format(e) + 'ε',
marker=markers[i_e],
markersize=lmdk_lib.marker_size,
markeredgewidth=0,
@ -94,14 +93,14 @@ def main(args):
color = '#212121',
linewidth=lmdk_lib.line_width
)
plt.text(x_i[-1] + x_i[-1]*.01, mae_evt - mae_evt*.14, 'event')
plt.text(x_i[-1] + x_i[-1]*.01, mae_evt - mae_evt*.04, 'event')
plt.axhline(
y = mae_usr,
color = '#616161',
linewidth=lmdk_lib.line_width
)
plt.text(x_i[-1] + x_i[-1]*.01, mae_usr - mae_usr*.14, 'user')
plt.text(x_i[-1] + x_i[-1]*.01, mae_usr - mae_usr*.04, 'user')
path = str('../../rslt/lmdk_sel_eps/' + d)
# Plot legend

View File

@ -45,13 +45,13 @@ def main(args):
bgt_conf = [
{'epsilon': 1},
]
eps_pct = [20, 40, 60, 80]
eps_pct = [.01, .1, .25, .5]
markers = [
'^', # 20
'v', # 40
'D', # 60
's' # 80
'^',
'v',
'D',
's'
]
# The x axis
@ -72,8 +72,6 @@ def main(args):
plt.xlim(x_i.min(), x_i.max())
# The y axis
plt.ylabel('Mean absolute error (m)') # Set y axis label.
plt.yscale('log')
plt.ylim(1, 1000000)
mae_evt = 0
mae_usr = 0
@ -88,10 +86,10 @@ def main(args):
for bgt in bgt_conf:
for _ in range(args.iter):
lmdks = lmdk_sel.find_lmdks_eps(seq, lmdks, bgt['epsilon']*e/100)
lmdks_sel = lmdk_sel.find_lmdks_eps(seq, lmdks, bgt['epsilon']*e)
# Uniform
rls_data_u, _ = lmdk_bgt.uniform_r(seq, lmdks, bgt['epsilon']*(1 - e/100))
rls_data_u, _ = lmdk_bgt.uniform_r(seq, lmdks_sel, bgt['epsilon']*(1 - e))
mae[i] += lmdk_bgt.mae(seq, rls_data_u)/args.iter
# Calculate once
@ -108,7 +106,7 @@ def main(args):
plt.plot(
x_i,
mae,
label=str(e/100) + 'ε',
label='{0:.2f}'.format(e) + 'ε',
marker=markers[i_e],
markersize=lmdk_lib.marker_size,
markeredgewidth=0,