diff --git a/code/parse_copenhagen.py b/code/parse_copenhagen.py index 00fa8f7..59a86d6 100644 --- a/code/parse_copenhagen.py +++ b/code/parse_copenhagen.py @@ -60,11 +60,13 @@ def main(args): # Get all users usrs = np.unique(np.concatenate((cont_data[:, uid_a], cont_data[:, uid_b]), 0)) # Check each user - goal = [.2, .4, .6, .8, 1] + goal = [.2, .4, .6, .8] # Users suitable for experiments usrs_expt = [] for usr_i, usr in enumerate(usrs): + usr = (14) print('Checking %d (%d%%: %d/%d)... ' %(usr, (usr_i + 1)*100/len(usrs), usr_i + 1, len(usrs)), end='', flush=True) + usrs_expt_cur = [] # User's contacts usr_cont = cont_data[(cont_data[:, uid_a] == usr) | (cont_data[:, uid_b] == usr)] # For each goal @@ -79,19 +81,20 @@ def main(args): # Check for every possible contact for u in usrs_cur: # Add possible contacts gradually - pos_cont.append(u) + pos_cont.append(int(u)) # Remove from user contacts usr_cont_cur = np.copy(usr_cont) for pos_c in pos_cont: usr_cont_cur = usr_cont_cur[(usr_cont_cur[:, uid_a] != pos_c) & (usr_cont_cur[:, uid_b] != pos_c)] # Compare the difference diff = (len(usr_cont) - len(usr_cont_cur))/len(usr_cont) - # Check if it's close enough to what we need - if abs(diff - g)/g < .025: - usrs_expt.append([usr, g, pos_cont]) - if g == 1: + # Check if it is close enough to what we need + if abs(diff - g)/g < .01: + usrs_expt_cur.append([int(usr), g, str(pos_cont)]) + if g == goal[len(goal) - 1]: # That's a keeper print('[OK]') + usrs_expt += usrs_expt_cur break elif diff > g: print('[NOK]')