diff --git a/code/parse_copenhagen.py b/code/parse_copenhagen.py index b6b1c3d..6ef312e 100644 --- a/code/parse_copenhagen.py +++ b/code/parse_copenhagen.py @@ -78,8 +78,10 @@ def main(args): print('[Error: %s]' %(e)) except Exception as e: print('[Error: %s]' %(e)) + # Remove duplicates + cont_data = np.unique(np.array(cont, np.float32), axis=0) # Save to results - lmdk_lib.save_data(args, np.array(cont, np.float32), 'cont') + lmdk_lib.save_data(args, cont_data, 'cont') ''' Get users' landmarks ''' @@ -129,30 +131,30 @@ def main(args): break # Save to results lmdk_lib.save_data(args, np.array(usrs_expt, str), 'usrs_expt') - # # Get all users - # usrs = np.unique(usrs_expt[:, 0]) - # for usr in usrs: - # usr_cont = cont_data[cont_data[:, uid_a] == float(usr)] - # print(int(usr), len(usr_cont)) - # exit() - ''' - Get contacts for user 623 - 9378 contacts - ''' - usr = '623' - # All user contacts - usr_cont = cont_data[cont_data[:, uid_a] == float(usr)] - # All user landmarks for different goals - usr_lmdk = usrs_expt[usrs_expt[:, 0] == usr] - for g in goal: - # Get goal landmarks - cont = ast.literal_eval(usr_lmdk[usr_lmdk[:, 1] == str(g)][0][2]) - usr_cont_cur = np.copy(usr_cont) - # Remove goal landmarks from contacts - for c in cont: - usr_cont_cur = usr_cont_cur[usr_cont_cur[:, uid_b] != c] - # Check - print(g, (len(usr_cont) - len(usr_cont_cur))/len(usr_cont)) + # Get all users + usrs = np.unique(usrs_expt[:, 0]) + for usr in usrs: + usr_cont = cont_data[cont_data[:, uid_a] == float(usr)] + print(int(usr), len(usr_cont)) + exit() + # ''' + # Get contacts for user 623 + # 9378 contacts + # ''' + # usr = '623' + # # All user contacts + # usr_cont = cont_data[cont_data[:, uid_a] == float(usr)] + # # All user landmarks for different goals + # usr_lmdk = usrs_expt[usrs_expt[:, 0] == usr] + # for g in goal: + # # Get goal landmarks + # cont = ast.literal_eval(usr_lmdk[usr_lmdk[:, 1] == str(g)][0][2]) + # usr_cont_cur = np.copy(usr_cont) + # # Remove goal landmarks from contacts + # for c in cont: + # usr_cont_cur = usr_cont_cur[usr_cont_cur[:, uid_b] != c] + # # Check + # print(g, (len(usr_cont) - len(usr_cont_cur))/len(usr_cont)) '''