code: Compare sel with original
This commit is contained in:
parent
d0dcc654ba
commit
2481a751ae
@ -57,8 +57,11 @@ def main(args):
|
|||||||
x_offset = -(bar_width/2)*(n - 1)
|
x_offset = -(bar_width/2)*(n - 1)
|
||||||
|
|
||||||
mae_u = np.zeros(len(lmdks_pct))
|
mae_u = np.zeros(len(lmdks_pct))
|
||||||
|
mae_u_sel= np.zeros(len(lmdks_pct))
|
||||||
mae_s = np.zeros(len(lmdks_pct))
|
mae_s = np.zeros(len(lmdks_pct))
|
||||||
|
mae_s_sel = np.zeros(len(lmdks_pct))
|
||||||
mae_a = np.zeros(len(lmdks_pct))
|
mae_a = np.zeros(len(lmdks_pct))
|
||||||
|
mae_a_sel = np.zeros(len(lmdks_pct))
|
||||||
mae_evt = 0
|
mae_evt = 0
|
||||||
mae_usr = 0
|
mae_usr = 0
|
||||||
|
|
||||||
@ -71,16 +74,22 @@ def main(args):
|
|||||||
lmdks_sel, eps_out = lmdk_sel.find_lmdks(seq, lmdks, epsilon)
|
lmdks_sel, eps_out = lmdk_sel.find_lmdks(seq, lmdks, epsilon)
|
||||||
|
|
||||||
# Skip
|
# Skip
|
||||||
rls_data_s, _ = lmdk_bgt.skip_cont(seq, lmdks_sel, eps_out)
|
rls_data_s, _ = lmdk_bgt.skip_cont(seq, lmdks, eps_out)
|
||||||
mae_s[i] += (lmdk_bgt.mae_cont(rls_data_s)/args.iter)*100
|
mae_s[i] += (lmdk_bgt.mae_cont(rls_data_s)/args.iter)*100
|
||||||
|
rls_data_s_sel, _ = lmdk_bgt.skip_cont(seq, lmdks_sel, eps_out)
|
||||||
|
mae_s_sel[i] += (lmdk_bgt.mae_cont(rls_data_s_sel)/args.iter)*100
|
||||||
|
|
||||||
# Uniform
|
# Uniform
|
||||||
rls_data_u, _ = lmdk_bgt.uniform_cont(seq, lmdks_sel, eps_out)
|
rls_data_u, _ = lmdk_bgt.uniform_cont(seq, lmdks, eps_out)
|
||||||
mae_u[i] += (lmdk_bgt.mae_cont(rls_data_u)/args.iter)*100
|
mae_u[i] += (lmdk_bgt.mae_cont(rls_data_u)/args.iter)*100
|
||||||
|
rls_data_u_sel, _ = lmdk_bgt.uniform_cont(seq, lmdks_sel, eps_out)
|
||||||
|
mae_u_sel[i] += (lmdk_bgt.mae_cont(rls_data_u_sel)/args.iter)*100
|
||||||
|
|
||||||
# Adaptive
|
# Adaptive
|
||||||
rls_data_a, _, _ = lmdk_bgt.adaptive_cont(seq, lmdks_sel, eps_out, .5, .5)
|
rls_data_a, _, _ = lmdk_bgt.adaptive_cont(seq, lmdks, eps_out, .5, .5)
|
||||||
mae_a[i] += (lmdk_bgt.mae_cont(rls_data_a)/args.iter)*100
|
mae_a[i] += (lmdk_bgt.mae_cont(rls_data_a)/args.iter)*100
|
||||||
|
rls_data_a_sel, _, _ = lmdk_bgt.adaptive_cont(seq, lmdks_sel, eps_out, .5, .5)
|
||||||
|
mae_a_sel[i] += (lmdk_bgt.mae_cont(rls_data_a_sel)/args.iter)*100
|
||||||
|
|
||||||
# Calculate once
|
# Calculate once
|
||||||
if pct == lmdks_pct[0]:
|
if pct == lmdks_pct[0]:
|
||||||
@ -106,29 +115,57 @@ def main(args):
|
|||||||
)
|
)
|
||||||
plt.text(x_i[-1] + x_i[-1]*.14, mae_usr - mae_usr*.05, 'user')
|
plt.text(x_i[-1] + x_i[-1]*.14, mae_usr - mae_usr*.05, 'user')
|
||||||
|
|
||||||
|
# Plot bars
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_s,
|
mae_s_sel,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Skip',
|
label='Skip',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
x_offset += bar_width
|
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_u,
|
mae_s,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Uniform',
|
color='none',
|
||||||
|
linestyle='dashed',
|
||||||
|
edgecolor='#bdbdbd',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_a,
|
mae_u_sel,
|
||||||
|
bar_width,
|
||||||
|
label='Uniform',
|
||||||
|
linewidth=lmdk_lib.line_width
|
||||||
|
)
|
||||||
|
plt.bar(
|
||||||
|
x_i + x_offset,
|
||||||
|
mae_u,
|
||||||
|
bar_width,
|
||||||
|
color='none',
|
||||||
|
linestyle='dashed',
|
||||||
|
edgecolor='#bdbdbd',
|
||||||
|
linewidth=lmdk_lib.line_width
|
||||||
|
)
|
||||||
|
x_offset += bar_width
|
||||||
|
plt.bar(
|
||||||
|
x_i + x_offset,
|
||||||
|
mae_a_sel,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Adaptive',
|
label='Adaptive',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
|
plt.bar(
|
||||||
|
x_i + x_offset,
|
||||||
|
mae_a,
|
||||||
|
bar_width,
|
||||||
|
color='none',
|
||||||
|
linestyle='dashed',
|
||||||
|
edgecolor='#bdbdbd',
|
||||||
|
linewidth=lmdk_lib.line_width
|
||||||
|
)
|
||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
|
|
||||||
path = str('../../rslt/bgt_cmp/' + d)
|
path = str('../../rslt/bgt_cmp/' + d)
|
||||||
@ -137,7 +174,7 @@ def main(args):
|
|||||||
# # Show plot
|
# # Show plot
|
||||||
# plt.show()
|
# plt.show()
|
||||||
# Save plot
|
# Save plot
|
||||||
lmdk_lib.save_plot(path + '-sel.pdf')
|
lmdk_lib.save_plot(path + '-sel-cmp.pdf')
|
||||||
print('[OK]', flush=True)
|
print('[OK]', flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import time
|
|||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
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')
|
||||||
# The name of the dataset
|
# The name of the dataset
|
||||||
@ -53,8 +52,11 @@ def main(args):
|
|||||||
x_offset = -(bar_width/2)*(n - 1)
|
x_offset = -(bar_width/2)*(n - 1)
|
||||||
|
|
||||||
mae_u = np.zeros(len(lmdks_pct))
|
mae_u = np.zeros(len(lmdks_pct))
|
||||||
|
mae_u_sel= np.zeros(len(lmdks_pct))
|
||||||
mae_s = np.zeros(len(lmdks_pct))
|
mae_s = np.zeros(len(lmdks_pct))
|
||||||
|
mae_s_sel = np.zeros(len(lmdks_pct))
|
||||||
mae_a = np.zeros(len(lmdks_pct))
|
mae_a = np.zeros(len(lmdks_pct))
|
||||||
|
mae_a_sel = np.zeros(len(lmdks_pct))
|
||||||
mae_evt = 0
|
mae_evt = 0
|
||||||
mae_usr = 0
|
mae_usr = 0
|
||||||
|
|
||||||
@ -67,16 +69,22 @@ def main(args):
|
|||||||
lmdks_sel, eps_out = lmdk_sel.find_lmdks(seq, lmdks, epsilon)
|
lmdks_sel, eps_out = lmdk_sel.find_lmdks(seq, lmdks, epsilon)
|
||||||
|
|
||||||
# Skip
|
# Skip
|
||||||
rls_data_s, _ = lmdk_bgt.skip_cons(seq, lmdks_sel, eps_out)
|
rls_data_s, _ = lmdk_bgt.skip_cons(seq, lmdks, eps_out)
|
||||||
mae_s[i] += lmdk_bgt.mae_cons(seq, rls_data_s)/args.iter
|
mae_s[i] += (lmdk_bgt.mae_cons(seq, rls_data_s)/args.iter)*100
|
||||||
|
rls_data_s_sel, _ = lmdk_bgt.skip_cons(seq, lmdks_sel, eps_out)
|
||||||
|
mae_s_sel[i] += (lmdk_bgt.mae_cons(seq, rls_data_s_sel)/args.iter)*100
|
||||||
|
|
||||||
# Uniform
|
# Uniform
|
||||||
rls_data_u, _ = lmdk_bgt.uniform_cons(seq, lmdks_sel, eps_out)
|
rls_data_u, _ = lmdk_bgt.uniform_cons(seq, lmdks, eps_out)
|
||||||
mae_u[i] += lmdk_bgt.mae_cons(seq, rls_data_u)/args.iter
|
mae_u[i] += (lmdk_bgt.mae_cons(seq, rls_data_u)/args.iter)*100
|
||||||
|
rls_data_u_sel, _ = lmdk_bgt.uniform_cons(seq, lmdks_sel, eps_out)
|
||||||
|
mae_u_sel[i] += (lmdk_bgt.mae_cons(seq, rls_data_u_sel)/args.iter)*100
|
||||||
|
|
||||||
# Adaptive
|
# Adaptive
|
||||||
rls_data_a, _, _ = lmdk_bgt.adaptive_cons(seq, lmdks_sel, eps_out, .5, .5)
|
rls_data_a, _, _ = lmdk_bgt.adaptive_cons(seq, lmdks, eps_out, .5, .5)
|
||||||
mae_a[i] += lmdk_bgt.mae_cons(seq, rls_data_a)/args.iter
|
mae_a[i] += (lmdk_bgt.mae_cons(seq, rls_data_a)/args.iter)*100
|
||||||
|
rls_data_a_sel, _, _ = lmdk_bgt.adaptive_cons(seq, lmdks_sel, eps_out, .5, .5)
|
||||||
|
mae_a_sel[i] += (lmdk_bgt.mae_cons(seq, rls_data_a_sel)/args.iter)*100
|
||||||
|
|
||||||
# Calculate once
|
# Calculate once
|
||||||
if pct == lmdks_pct[0]:
|
if pct == lmdks_pct[0]:
|
||||||
@ -102,29 +110,57 @@ def main(args):
|
|||||||
)
|
)
|
||||||
plt.text(x_i[-1] + x_i[-1]*.14, mae_usr - mae_usr*.14, 'user')
|
plt.text(x_i[-1] + x_i[-1]*.14, mae_usr - mae_usr*.14, 'user')
|
||||||
|
|
||||||
|
# Plot bars
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_s,
|
mae_s_sel,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Skip',
|
label='Skip',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
x_offset += bar_width
|
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_u,
|
mae_s,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Uniform',
|
color='none',
|
||||||
|
linestyle='dashed',
|
||||||
|
edgecolor='#bdbdbd',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_a,
|
mae_u_sel,
|
||||||
|
bar_width,
|
||||||
|
label='Uniform',
|
||||||
|
linewidth=lmdk_lib.line_width
|
||||||
|
)
|
||||||
|
plt.bar(
|
||||||
|
x_i + x_offset,
|
||||||
|
mae_u,
|
||||||
|
bar_width,
|
||||||
|
color='none',
|
||||||
|
linestyle='dashed',
|
||||||
|
edgecolor='#bdbdbd',
|
||||||
|
linewidth=lmdk_lib.line_width
|
||||||
|
)
|
||||||
|
x_offset += bar_width
|
||||||
|
plt.bar(
|
||||||
|
x_i + x_offset,
|
||||||
|
mae_a_sel,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Adaptive',
|
label='Adaptive',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
|
plt.bar(
|
||||||
|
x_i + x_offset,
|
||||||
|
mae_a,
|
||||||
|
bar_width,
|
||||||
|
color='none',
|
||||||
|
linestyle='dashed',
|
||||||
|
edgecolor='#bdbdbd',
|
||||||
|
linewidth=lmdk_lib.line_width
|
||||||
|
)
|
||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
|
|
||||||
path = str('../../rslt/bgt_cmp/' + d)
|
path = str('../../rslt/bgt_cmp/' + d)
|
||||||
@ -133,7 +169,7 @@ def main(args):
|
|||||||
# Show plot
|
# Show plot
|
||||||
# plt.show()
|
# plt.show()
|
||||||
# Save plot
|
# Save plot
|
||||||
lmdk_lib.save_plot(path + '-sel.pdf')
|
lmdk_lib.save_plot(path + '-sel-cmp.pdf')
|
||||||
print('[OK]', flush=True)
|
print('[OK]', flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,8 +75,11 @@ def main(args):
|
|||||||
x_offset = -(bar_width/2)*(n - 1)
|
x_offset = -(bar_width/2)*(n - 1)
|
||||||
|
|
||||||
mae_u = np.zeros(len(data_info[d]['lmdks']))
|
mae_u = np.zeros(len(data_info[d]['lmdks']))
|
||||||
|
mae_u_sel= np.zeros(len(data_info[d]['lmdks']))
|
||||||
mae_s = np.zeros(len(data_info[d]['lmdks']))
|
mae_s = np.zeros(len(data_info[d]['lmdks']))
|
||||||
|
mae_s_sel = np.zeros(len(data_info[d]['lmdks']))
|
||||||
mae_a = np.zeros(len(data_info[d]['lmdks']))
|
mae_a = np.zeros(len(data_info[d]['lmdks']))
|
||||||
|
mae_a_sel = np.zeros(len(data_info[d]['lmdks']))
|
||||||
mae_evt = 0
|
mae_evt = 0
|
||||||
mae_usr = 0
|
mae_usr = 0
|
||||||
for i, lmdk in enumerate(data_info[d]['lmdks']):
|
for i, lmdk in enumerate(data_info[d]['lmdks']):
|
||||||
@ -90,16 +93,22 @@ def main(args):
|
|||||||
lmdks_sel, eps_out = lmdk_sel.find_lmdks(seq, lmdks, bgt['epsilon'])
|
lmdks_sel, eps_out = lmdk_sel.find_lmdks(seq, lmdks, bgt['epsilon'])
|
||||||
|
|
||||||
# Skip
|
# Skip
|
||||||
rls_data_s, _ = lmdk_bgt.skip(seq, lmdks_sel, eps_out)
|
rls_data_s, _ = lmdk_bgt.skip(seq, lmdks, eps_out)
|
||||||
mae_s[i] += lmdk_bgt.mae(seq, rls_data_s)/args.iter
|
mae_s[i] += (lmdk_bgt.mae(seq, rls_data_s)/args.iter)*100
|
||||||
|
rls_data_s_sel, _ = lmdk_bgt.skip(seq, lmdks_sel, eps_out)
|
||||||
|
mae_s_sel[i] += (lmdk_bgt.mae(seq, rls_data_s_sel)/args.iter)*100
|
||||||
|
|
||||||
# Uniform
|
# Uniform
|
||||||
rls_data_u, _ = lmdk_bgt.uniform_r(seq, lmdks_sel, eps_out)
|
rls_data_u, _ = lmdk_bgt.uniform_r(seq, lmdks, eps_out)
|
||||||
mae_u[i] += lmdk_bgt.mae(seq, rls_data_u)/args.iter
|
mae_u[i] += (lmdk_bgt.mae(seq, rls_data_u)/args.iter)*100
|
||||||
|
rls_data_u_sel, _ = lmdk_bgt.uniform_r(seq, lmdks_sel, eps_out)
|
||||||
|
mae_u_sel[i] += (lmdk_bgt.mae(seq, rls_data_u_sel)/args.iter)*100
|
||||||
|
|
||||||
# Adaptive
|
# Adaptive
|
||||||
rls_data_a, _, _ = lmdk_bgt.adaptive(seq, lmdks_sel, eps_out, .5, .5)
|
rls_data_a, _, _ = lmdk_bgt.adaptive(seq, lmdks, eps_out, .5, .5)
|
||||||
mae_a[i] += lmdk_bgt.mae(seq, rls_data_a)/args.iter
|
mae_a[i] += (lmdk_bgt.mae(seq, rls_data_a)/args.iter)*100
|
||||||
|
rls_data_a_sel, _, _ = lmdk_bgt.adaptive(seq, lmdks_sel, eps_out, .5, .5)
|
||||||
|
mae_a_sel[i] += (lmdk_bgt.mae(seq, rls_data_a_sel)/args.iter)*100
|
||||||
|
|
||||||
# Calculate once
|
# Calculate once
|
||||||
if lmdk == min(data_info[d]['lmdks']):
|
if lmdk == min(data_info[d]['lmdks']):
|
||||||
@ -128,27 +137,55 @@ def main(args):
|
|||||||
# Plot bars
|
# Plot bars
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_s,
|
mae_s_sel,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Skip',
|
label='Skip',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
|
plt.bar(
|
||||||
|
x_i + x_offset,
|
||||||
|
mae_s,
|
||||||
|
bar_width,
|
||||||
|
color='none',
|
||||||
|
linestyle='dashed',
|
||||||
|
edgecolor='#bdbdbd',
|
||||||
|
linewidth=lmdk_lib.line_width
|
||||||
|
)
|
||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_u,
|
mae_u_sel,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Uniform',
|
label='Uniform',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
|
plt.bar(
|
||||||
|
x_i + x_offset,
|
||||||
|
mae_u,
|
||||||
|
bar_width,
|
||||||
|
color='none',
|
||||||
|
linestyle='dashed',
|
||||||
|
edgecolor='#bdbdbd',
|
||||||
|
linewidth=lmdk_lib.line_width
|
||||||
|
)
|
||||||
x_offset += bar_width
|
x_offset += bar_width
|
||||||
plt.bar(
|
plt.bar(
|
||||||
x_i + x_offset,
|
x_i + x_offset,
|
||||||
mae_a,
|
mae_a_sel,
|
||||||
bar_width,
|
bar_width,
|
||||||
label='Adaptive',
|
label='Adaptive',
|
||||||
linewidth=lmdk_lib.line_width
|
linewidth=lmdk_lib.line_width
|
||||||
)
|
)
|
||||||
|
plt.bar(
|
||||||
|
x_i + x_offset,
|
||||||
|
mae_a,
|
||||||
|
bar_width,
|
||||||
|
color='none',
|
||||||
|
linestyle='dashed',
|
||||||
|
edgecolor='#bdbdbd',
|
||||||
|
linewidth=lmdk_lib.line_width
|
||||||
|
)
|
||||||
|
x_offset += bar_width
|
||||||
|
|
||||||
path = str('../../rslt/bgt_cmp/' + d)
|
path = str('../../rslt/bgt_cmp/' + d)
|
||||||
# Plot legend
|
# Plot legend
|
||||||
@ -156,7 +193,7 @@ def main(args):
|
|||||||
# Show plot
|
# Show plot
|
||||||
# plt.show()
|
# plt.show()
|
||||||
# Save plot
|
# Save plot
|
||||||
lmdk_lib.save_plot(path + '-sel.pdf')
|
lmdk_lib.save_plot(path + '-sel-cmp.pdf')
|
||||||
print('[OK]', flush=True)
|
print('[OK]', flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user