evaluation: Minor corrections and text

This commit is contained in:
2021-10-11 04:01:08 +02:00
parent d5c39c4e42
commit 6080efece9
6 changed files with 72 additions and 21 deletions

View File

@ -20,7 +20,15 @@ def main(args):
# Distribution type
dist_type = np.array(range(0, 4))
# Number of landmarks
lmdk_n = np.array(range(int(.2*args.time), args.time, int(args.time/5)))
lmdk_n = np.array(range(0, args.time + 1, int(args.time/5)))
markers = [
'^', # Symmetric
'v', # Skewed
'D', # Bimodal
's' # Uniform
]
# Initialize plot
lmdk_lib.plot_init()
# Width of bars
@ -30,11 +38,13 @@ def main(args):
x_margin = bar_width*(len(dist_type)/2 + 1)
plt.xticks(x_i, ((lmdk_n/len(seq))*100).astype(int))
plt.xlabel('Landmarks (%)') # Set x axis label.
plt.xlim(x_i.min() - x_margin, x_i.max() + x_margin)
# plt.xlim(x_i.min() - x_margin, x_i.max() + x_margin)
plt.xlim(x_i.min(), x_i.max())
# The y axis
# plt.yscale('log')
plt.ylabel('Euclidean distance') # Set y axis label.
# plt.ylabel('Wasserstein distance') # Set y axis label.
plt.ylim(0, 1)
plt.ylabel('Normalized Euclidean distance') # Set y axis label.
# plt.ylabel('Normalized Wasserstein distance') # Set y axis label.
# Bar offset
x_offset = -(bar_width/2)*(len(dist_type) - 1)
for d_i, d in enumerate(dist_type):
@ -47,27 +57,41 @@ def main(args):
print('(%d/%d) %s... ' %(d_i + 1, len(dist_type), title), end='', flush=True)
mae = np.zeros(len(lmdk_n))
for n_i, n in enumerate(lmdk_n):
for r in range(args.reps):
if n == lmdk_n[-1]:
break
for r in range(args.iter):
lmdks = lmdk_lib.get_lmdks(seq, n, d)
hist, h = lmdk_lib.get_hist(seq, lmdks)
opts = lmdk_sel.get_opts_from_top_h(seq, lmdks)
delta = 1.0
res, _ = exp_mech.exponential(hist, opts, exp_mech.score, delta, epsilon)
mae[n_i] += lmdk_lib.get_norm(hist, res)/args.reps # Euclidean
# mae[n_i] += lmdk_lib.get_emd(hist, res)/args.reps # Wasserstein
mae[n_i] += lmdk_lib.get_norm(hist, res)/args.iter # Euclidean
# mae[n_i] += lmdk_lib.get_emd(hist, res)/args.iter # Wasserstein
mae = mae/21 # Euclidean
# mae = mae/11.75 # Wasserstein
print('[OK]', flush=True)
# Plot bar for current distribution
plt.bar(
x_i + x_offset,
# # Plot bar for current distribution
# plt.bar(
# x_i + x_offset,
# mae,
# bar_width,
# label=label,
# linewidth=lmdk_lib.line_width
# )
# # Change offset for next bar
# x_offset += bar_width
# Plot line
plt.plot(
x_i,
mae,
bar_width,
label=label,
marker=markers[d_i],
markersize=lmdk_lib.marker_size,
markeredgewidth=0,
linewidth=lmdk_lib.line_width
)
# Change offset for next bar
x_offset += bar_width
path = str('../../rslt/lmdk_sel_cmp/' + 'lmdk_sel_cmp-norm')
# path = str('../../rslt/lmdk_sel_cmp/' + 'lmdk_sel_cmp-emd')
path = str('../../rslt/lmdk_sel_cmp/' + 'lmdk_sel_cmp-norm-l')
# path = str('../../rslt/lmdk_sel_cmp/' + 'lmdk_sel_cmp-emd-l')
# Plot legend
lmdk_lib.plot_legend()
# Show plot
@ -81,7 +105,7 @@ def main(args):
Parse arguments.
Optional:
reps - The number of repetitions.
iter - The number of iterations.
time - The time limit of the sequence.
'''
def parse_args():
@ -91,7 +115,7 @@ def parse_args():
# Mandatory 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)
# Parse arguments.