t-drive: Debugging

This commit is contained in:
Manos Katsomallos 2021-10-08 20:14:21 +02:00
parent ceab96bea3
commit 2e5983ff72
2 changed files with 18 additions and 9 deletions

View File

@ -75,14 +75,16 @@ def main(args):
mae_u = np.zeros(len(data_info[d]['lmdks'])) mae_u = 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_a = np.zeros(len(data_info[d]['lmdks'])) mae_a = np.zeros(len(data_info[d]['lmdks']))
mae_d = 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']):
# Find landmarks # Find landmarks
args.dist = data_info[d]['lmdks'][lmdk]['dist'] args.dist = data_info[d]['lmdks'][lmdk]['dist']
args.per = data_info[d]['lmdks'][lmdk]['per'] args.per = data_info[d]['lmdks'][lmdk]['per']
lmdks = lmdk_lib.find_lmdks(seq, args)[:args.time] lmdks = lmdk_lib.find_lmdks(seq, args)
for bgt in bgt_conf: for bgt in bgt_conf:
s_d = 0
for _ in range(args.iter): for _ in range(args.iter):
# Skip # Skip
rls_data_s, _ = lmdk_bgt.skip(seq, lmdks, bgt['epsilon']) rls_data_s, _ = lmdk_bgt.skip(seq, lmdks, bgt['epsilon'])
@ -96,6 +98,11 @@ def main(args):
rls_data_a, _, _ = lmdk_bgt.adaptive(seq, lmdks, bgt['epsilon'], .5, .5) rls_data_a, _, _ = lmdk_bgt.adaptive(seq, lmdks, bgt['epsilon'], .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
# # Dynamic
# rls_data_a, _, s_d_c = lmdk_bgt.dynamic(seq, lmdks, bgt['epsilon'], .5, .5)
# mae_d[i] += lmdk_bgt.mae(seq, rls_data_a)/args.iter
# s_d += s_d_c/args.iter
# Event # Event
if lmdk == 0: if lmdk == 0:
rls_data_evt, _ = lmdk_bgt.uniform_r(seq, lmdks, bgt['epsilon']) rls_data_evt, _ = lmdk_bgt.uniform_r(seq, lmdks, bgt['epsilon'])
@ -143,6 +150,14 @@ def main(args):
label='Adaptive', label='Adaptive',
linewidth=lmdk_lib.line_width linewidth=lmdk_lib.line_width
) )
# x_offset += bar_width
# plt.bar(
# x_i + x_offset,
# mae_d,
# bar_width,
# label='Dynamic',
# linewidth=lmdk_lib.line_width
# )
path = str('../../rslt/bgt_cmp/' + d) path = str('../../rslt/bgt_cmp/' + d)
# Plot legend # Plot legend

View File

@ -856,7 +856,6 @@ def find_lmdks(usrs_data, args):
''' '''
usrs_lmdks = np.empty((0,4), np.float32) usrs_lmdks = np.empty((0,4), np.float32)
traj_cur = 0 traj_cur = 0
lmdk_id = 0
usrs = np.unique(usrs_data[:,0]) usrs = np.unique(usrs_data[:,0])
for usr_i, usr in enumerate(usrs): for usr_i, usr in enumerate(usrs):
# Initialize user's landmarks list # Initialize user's landmarks list
@ -888,11 +887,6 @@ def find_lmdks(usrs_data, args):
per = abs(datetime.fromtimestamp(int(traj[i][3])) - datetime.fromtimestamp(int(traj[j][3]))).total_seconds()/60 per = abs(datetime.fromtimestamp(int(traj[i][3])) - datetime.fromtimestamp(int(traj[j][3]))).total_seconds()/60
# Check if enough time passed # Check if enough time passed
if per > args.per: if per > args.per:
# usrs_id starts from 1
lmdk_id += 1
# Assign id to current landmark
for l in lmdk_cur:
l[0] = lmdk_id
# Append current landmark # Append current landmark
lmdks += lmdk_cur lmdks += lmdk_cur
# Continue checking from the current point # Continue checking from the current point
@ -910,7 +904,7 @@ def find_lmdks(usrs_data, args):
def find_lmdks_seq(seq, lmdks): def find_lmdks_seq(seq, lmdks):
lmdks_seq = [] lmdks_seq = []
for i, p in enumerate(seq): for i, p in enumerate(seq):
if any(np.equal(lmdks, p).all(1)): if is_landmark(p, lmdks):
lmdks_seq.append(i + 1) lmdks_seq.append(i + 1)
return np.array(lmdks_seq, dtype = int) return np.array(lmdks_seq, dtype = int)
@ -1073,6 +1067,6 @@ def is_landmark(p, lmdks):
Returns: Returns:
True/False True/False
''' '''
if len(lmdks) and any(np.equal(lmdks, p).all(1)): if len(lmdks) > 0 and any(np.equal(lmdks, p).all(1)):
return True return True
return False return False