parse_copenhagen: Working only with ego

This commit is contained in:
Manos Katsomallos 2021-09-28 20:31:13 +02:00
parent a0f2708cdb
commit 70525a5ae6

View File

@ -17,62 +17,62 @@ import time
import zipfile import zipfile
''' '''
usr n usr n
109 6549 109 6549
112 3277 112 3277
113 4202 113 4202
139 8681 139 8681
14 9378 14 9378
145 4192 145 4192
147 4428 147 4428
157 11503 157 11503
164 8045 164 8045
17 4238 17 4238
176 19732 176 19732
178 7738 178 7738
186 3289 186 3289
190 13843 190 13843
216 6126 216 6126
236 3810 236 3810
244 10563 244 10563
262 17567 262 17567
264 9792 264 9792
274 11572 274 11572
275 4316 275 4316
287 13394 287 13394
299 7373 299 7373
304 6502 304 6502
317 3892 317 3892
324 11349 324 11349
344 14479 344 14479
374 5512 374 5512
383 18751 383 18751
389 3438 389 3438
396 7004 396 7004
453 3957 453 3957
474 7692 474 7692
480 4009 480 4009
504 2622 504 2622
505 11200 505 11200
561 4304 561 4304
570 2136 570 2136
576 6553 576 6553
58 12755 58 12755
593 3429 593 3429
595 4982 595 4982
619 6189 619 6189
633 5229 633 5229
657 10941 657 10941
658 1658 658 1658
663 11461 663 11461
688 19794 688 19794
691 6755 691 6755
705 5 705 5
76 4875 76 4875
77 25 77 25
79 8892 79 8892
81 8944 81 8944
88 17254 88 17254
''' '''
# https://cloud.delkappa.com/s/ACMsDr2jnW3b6Np # https://cloud.delkappa.com/s/ACMsDr2jnW3b6Np
@ -123,7 +123,7 @@ def main(args):
Get users' landmarks Get users' landmarks
''' '''
# Get all users # Get all users
usrs = np.unique(np.concatenate((cont_data[:, uid_a], cont_data[:, uid_b]), 0)) usrs = np.unique(cont_data[:, uid_a])
# Check each user # Check each user
goal = [.2, .4, .6, .8] goal = [.2, .4, .6, .8]
# Get users' data from previous parsing # Get users' data from previous parsing
@ -135,7 +135,7 @@ def main(args):
print('Checking %d (%d%%: %d/%d)... ' %(usr, (usr_i + 1)*100/len(usrs), usr_i + 1, len(usrs)), end='', flush=True) print('Checking %d (%d%%: %d/%d)... ' %(usr, (usr_i + 1)*100/len(usrs), usr_i + 1, len(usrs)), end='', flush=True)
usrs_expt_cur = [] usrs_expt_cur = []
# User's contacts # User's contacts
usr_cont = cont_data[(cont_data[:, uid_a] == usr) | (cont_data[:, uid_b] == usr)] usr_cont = cont_data[cont_data[:, uid_a] == usr]
# For each goal # For each goal
for_expt = True for_expt = True
for g in goal: for g in goal:
@ -152,7 +152,7 @@ def main(args):
# Remove from user contacts # Remove from user contacts
usr_cont_cur = np.copy(usr_cont) usr_cont_cur = np.copy(usr_cont)
for pos_c in pos_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)] usr_cont_cur = usr_cont_cur[usr_cont_cur[:, uid_a] != pos_c]
# Compare the difference # Compare the difference
diff = (len(usr_cont) - len(usr_cont_cur))/len(usr_cont) diff = (len(usr_cont) - len(usr_cont_cur))/len(usr_cont)
# Check if it is close enough to what we need # Check if it is close enough to what we need
@ -167,12 +167,14 @@ def main(args):
print('[NOK]') print('[NOK]')
for_expt = False for_expt = False
break break
# This user is no bueno
print('[NOK]')
# Save to results # Save to results
lmdk_lib.save_data(args, np.array(usrs_expt, str), 'usrs_expt') lmdk_lib.save_data(args, np.array(usrs_expt, str), 'usrs_expt')
# Get all users # Get all users
# usrs = np.unique(usrs_expt[:, 0]) # usrs = np.unique(usrs_expt[:, 0])
# for usr in usrs: # for usr in usrs:
# usr_cont = cont_data[(cont_data[:, uid_a] == float(usr)) | (cont_data[:, uid_b] == float(usr))] # usr_cont = cont_data[cont_data[:, uid_a] == float(usr)]
# print(int(usr), len(usr_cont)) # print(int(usr), len(usr_cont))
# exit() # exit()
''' '''
@ -181,7 +183,7 @@ def main(args):
''' '''
usr = '14' usr = '14'
# All user contacts # All user contacts
usr_cont = cont_data[(cont_data[:, uid_a] == float(usr)) | (cont_data[:, uid_b] == float(usr))] usr_cont = cont_data[cont_data[:, uid_a] == float(usr)]
# All user landmarks for different goals # All user landmarks for different goals
usr_lmdk = usrs_expt[usrs_expt[:, 0] == usr] usr_lmdk = usrs_expt[usrs_expt[:, 0] == usr]
for g in goal: for g in goal:
@ -190,7 +192,7 @@ def main(args):
usr_cont_cur = np.copy(usr_cont) usr_cont_cur = np.copy(usr_cont)
# Remove goal landmarks from contacts # Remove goal landmarks from contacts
for c in cont: for c in cont:
usr_cont_cur = usr_cont_cur[(usr_cont_cur[:, uid_a] != c) & (usr_cont_cur[:, uid_b] != c)] usr_cont_cur = usr_cont_cur[usr_cont_cur[:, uid_a] != c]
# Check # Check
print(g, (len(usr_cont) - len(usr_cont_cur))/len(usr_cont)) print(g, (len(usr_cont) - len(usr_cont_cur))/len(usr_cont))