code: Final experiment corrections
This commit is contained in:
parent
427fbaf0ff
commit
f9c28dd03f
@ -118,15 +118,15 @@ def main(args):
|
|||||||
# Plot bars
|
# Plot bars
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_s_sel,
|
mae_s,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Skip',
|
label='Skip',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
plt.plot(
|
plt.plot(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_s,
|
mae_s_sel,
|
||||||
marker='_',
|
marker='+',
|
||||||
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
||||||
markeredgewidth=lmdk_lib.line_width,
|
markeredgewidth=lmdk_lib.line_width,
|
||||||
markeredgecolor='#bdbdbd',
|
markeredgecolor='#bdbdbd',
|
||||||
@ -135,15 +135,15 @@ def main(args):
|
|||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_u_sel,
|
mae_u,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Uniform',
|
label='Uniform',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
plt.plot(
|
plt.plot(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_u,
|
mae_u_sel,
|
||||||
marker='_',
|
marker='+',
|
||||||
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
||||||
markeredgewidth=lmdk_lib.line_width,
|
markeredgewidth=lmdk_lib.line_width,
|
||||||
markeredgecolor='#bdbdbd',
|
markeredgecolor='#bdbdbd',
|
||||||
@ -152,15 +152,15 @@ def main(args):
|
|||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_a_sel,
|
mae_a,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Adaptive',
|
label='Adaptive',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
plt.plot(
|
plt.plot(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_a,
|
mae_a_sel,
|
||||||
marker='_',
|
marker='+',
|
||||||
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
||||||
markeredgewidth=lmdk_lib.line_width,
|
markeredgewidth=lmdk_lib.line_width,
|
||||||
markeredgecolor='#bdbdbd',
|
markeredgecolor='#bdbdbd',
|
||||||
|
@ -45,7 +45,7 @@ def main(args):
|
|||||||
x_margin = bar_width*(len(dist_type)/2 + 1)
|
x_margin = bar_width*(len(dist_type)/2 + 1)
|
||||||
plt.xlim(x_i.min() - x_margin, x_i.max() + x_margin)
|
plt.xlim(x_i.min() - x_margin, x_i.max() + x_margin)
|
||||||
# The y axis
|
# The y axis
|
||||||
plt.ylabel('Privacy loss') # Set y axis label.
|
plt.ylabel('Temporal privacy loss') # Set y axis label.
|
||||||
plt.yscale('log')
|
plt.yscale('log')
|
||||||
plt.ylim(epsilon/10, 100*len(seq))
|
plt.ylim(epsilon/10, 100*len(seq))
|
||||||
# plt.ylim(0, 10000)
|
# plt.ylim(0, 10000)
|
||||||
@ -55,15 +55,15 @@ def main(args):
|
|||||||
e = np.zeros(len(lmdk_n))
|
e = np.zeros(len(lmdk_n))
|
||||||
a = np.zeros(len(lmdk_n))
|
a = np.zeros(len(lmdk_n))
|
||||||
for i, n in enumerate(lmdk_n):
|
for i, n in enumerate(lmdk_n):
|
||||||
for r in range(args.reps):
|
for r in range(args.iter):
|
||||||
# Generate landmarks
|
# Generate landmarks
|
||||||
lmdks = lmdk_lib.get_lmdks(seq, n, d)
|
lmdks = lmdk_lib.get_lmdks(seq, n, d)
|
||||||
# Uniform budget allocation
|
# Uniform budget allocation
|
||||||
e_cur = lmdk_bgt.uniform(seq, lmdks, epsilon)
|
e_cur = lmdk_bgt.uniform(seq, lmdks, epsilon)
|
||||||
_, _, a_cur = gdp.tpl_lmdk_mem(e_cur, p, p, seq, lmdks)
|
_, _, a_cur = gdp.tpl_lmdk_mem(e_cur, p, p, seq, lmdks)
|
||||||
# Save privacy loss
|
# Save privacy loss
|
||||||
e[i] += np.sum(e_cur)/args.reps
|
e[i] += np.sum(e_cur)/args.iter
|
||||||
a[i] += np.sum(a_cur)/args.reps
|
a[i] += np.sum(a_cur)/args.iter
|
||||||
# Set label
|
# Set label
|
||||||
label = lmdk_lib.dist_type_to_str(d_i)
|
label = lmdk_lib.dist_type_to_str(d_i)
|
||||||
if d_i == 1:
|
if d_i == 1:
|
||||||
@ -98,7 +98,7 @@ def main(args):
|
|||||||
Parse arguments.
|
Parse arguments.
|
||||||
|
|
||||||
Optional:
|
Optional:
|
||||||
reps - The number of repetitions.
|
iter - The number of iterations.
|
||||||
time - The time limit of the sequence.
|
time - The time limit of the sequence.
|
||||||
'''
|
'''
|
||||||
def parse_args():
|
def parse_args():
|
||||||
@ -108,7 +108,7 @@ def parse_args():
|
|||||||
# Mandatory arguments.
|
# Mandatory arguments.
|
||||||
|
|
||||||
# Optional arguments.
|
# Optional arguments.
|
||||||
parser.add_argument('-r', '--reps', help='The number of repetitions.', type=int, default=1)
|
parser.add_argument('-i', '--iter', help='The number of iterations.', type=int, default=1)
|
||||||
parser.add_argument('-t', '--time', help='The time limit of the sequence.', type=int, default=100)
|
parser.add_argument('-t', '--time', help='The time limit of the sequence.', type=int, default=100)
|
||||||
|
|
||||||
# Parse arguments.
|
# Parse arguments.
|
||||||
|
@ -113,15 +113,15 @@ def main(args):
|
|||||||
# Plot bars
|
# Plot bars
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_s_sel,
|
mae_s,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Skip',
|
label='Skip',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
plt.plot(
|
plt.plot(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_s,
|
mae_s_sel,
|
||||||
marker='_',
|
marker='+',
|
||||||
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
||||||
markeredgewidth=lmdk_lib.line_width,
|
markeredgewidth=lmdk_lib.line_width,
|
||||||
markeredgecolor='#bdbdbd',
|
markeredgecolor='#bdbdbd',
|
||||||
@ -130,15 +130,15 @@ def main(args):
|
|||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_u_sel,
|
mae_u,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Uniform',
|
label='Uniform',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
plt.plot(
|
plt.plot(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_u,
|
mae_u_sel,
|
||||||
marker='_',
|
marker='+',
|
||||||
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
||||||
markeredgewidth=lmdk_lib.line_width,
|
markeredgewidth=lmdk_lib.line_width,
|
||||||
markeredgecolor='#bdbdbd',
|
markeredgecolor='#bdbdbd',
|
||||||
@ -147,15 +147,15 @@ def main(args):
|
|||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_a_sel,
|
mae_a,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Adaptive',
|
label='Adaptive',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
plt.plot(
|
plt.plot(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_a,
|
mae_a_sel,
|
||||||
marker='_',
|
marker='+',
|
||||||
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
||||||
markeredgewidth=lmdk_lib.line_width,
|
markeredgewidth=lmdk_lib.line_width,
|
||||||
markeredgecolor='#bdbdbd',
|
markeredgecolor='#bdbdbd',
|
||||||
|
@ -137,15 +137,15 @@ def main(args):
|
|||||||
# Plot bars
|
# Plot bars
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_s_sel,
|
mae_s,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Skip',
|
label='Skip',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
plt.plot(
|
plt.plot(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_s,
|
mae_s_sel,
|
||||||
marker='_',
|
marker='+',
|
||||||
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
||||||
markeredgewidth=lmdk_lib.line_width,
|
markeredgewidth=lmdk_lib.line_width,
|
||||||
markeredgecolor='#bdbdbd',
|
markeredgecolor='#bdbdbd',
|
||||||
@ -154,15 +154,15 @@ def main(args):
|
|||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_u_sel,
|
mae_u,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Uniform',
|
label='Uniform',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
plt.plot(
|
plt.plot(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_u,
|
mae_u_sel,
|
||||||
marker='_',
|
marker='+',
|
||||||
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
||||||
markeredgewidth=lmdk_lib.line_width,
|
markeredgewidth=lmdk_lib.line_width,
|
||||||
markeredgecolor='#bdbdbd',
|
markeredgecolor='#bdbdbd',
|
||||||
@ -171,7 +171,7 @@ def main(args):
|
|||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_a_sel,
|
mae_a,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Adaptive',
|
label='Adaptive',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
@ -179,7 +179,7 @@ def main(args):
|
|||||||
plt.plot(
|
plt.plot(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_a,
|
mae_a,
|
||||||
marker='_',
|
marker='+',
|
||||||
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
markersize=lmdk_lib.marker_size + lmdk_lib.line_width,
|
||||||
markeredgewidth=lmdk_lib.line_width,
|
markeredgewidth=lmdk_lib.line_width,
|
||||||
markeredgecolor='#bdbdbd',
|
markeredgecolor='#bdbdbd',
|
||||||
|
Loading…
Reference in New Issue
Block a user