-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabulate.py
More file actions
118 lines (94 loc) · 5.09 KB
/
Copy pathtabulate.py
File metadata and controls
118 lines (94 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import sys
dataset = sys.argv[1]
source = sys.argv[2]
import os
directory = "results"
if not os.path.exists(directory):
os.makedirs(directory)
if dataset == "4square":
cities = ['Semarang', 'Manado', 'Chiang Mai', 'Davao', 'Salvador', 'Seremban', 'Merida', 'Toronto', 'Campo Grande', 'Kuantan New Port', 'Dubai', 'Riga', 'Phoenix', 'Ipoh', "Kazan'", 'Maceio', 'Baltimore', 'St. Louis', 'Panama', 'Rostov-on-Don', 'Sydney', 'Joao Pessoa', 'Puebla', 'Indianapolis', 'Minneapolis', 'Florianopolis', 'Miami', 'Charlotte', 'Mumbai', 'San Antonio', 'Villahermosa', 'Houston', 'Vancouver', 'Heredia', 'Alor Setar', 'Pathum Thani', 'Melbourne', 'Columbus', 'Newark', 'Seattle', 'Teresina', 'Milan', 'Saratov', 'Tampa', 'Santos', "Perm'", 'Minsk', 'Krasnoyarsk', 'Samsun', 'Kansas City', 'Pittsburgh', 'Portland', 'Vitoria', 'Konya', 'Austin', 'Cleveland', 'Rio de Janeiro', 'Detroit', 'Antwerpen', 'Santo Domingo', 'Dallas', 'Piraeus', 'Berlin', 'Amsterdam', 'Budapest', 'Brussels', 'Aintab', 'Denizli', 'Kayseri', 'Hong Kong', 'Rome', 'Kuwait', 'Fort-De-France', 'Manisa', 'Kobe', 'Balikesir', 'Sapporo', 'Gent', 'Sendai']
elif dataset == "wiki":
cities = ['ru','es','it','nl','zh','pt','pl','ja','vi','sv','uk','ko','ar','he','no','fa','cs','ca','simple',
'fi','tr','hu','sr','ro','bg','et','id','da','gl','eo','sk','hr','hi','ms','sl','nn','kk','eu']
elif dataset == "yelp":
cities = ['Voorhees', 'Harvey', 'Ambler', 'Mount Juliet', 'Plainfield', 'Plymouth Meeting', 'King Of Prussia', 'Edwardsville', 'Havertown', 'Kirkwood', 'Glen Mills', 'Ballwin', 'Hermitage', 'Collegeville', 'Avon', 'Treasure Island', 'Gretna', 'Eagle', 'Smyrna', 'Bryn Mawr', 'Seminole', 'Collingswood', 'Creve Coeur', 'Saint Charles', 'St Pete Beach', 'Indian Rocks Beach', 'North Wales', 'Langhorne', 'Newtown', 'Malvern', 'Lansdale', 'Norristown', 'Springfield', 'Willow Grove', 'Oldsmar', 'Phoenixville', 'Madeira Beach', 'Mount Laurel', 'Oro Valley', 'Exton', 'New Hope', 'Newark', 'Bensalem', 'Hendersonville', 'Clayton', 'Media', 'Conshohocken', 'Wayne', 'Marlton', 'Doylestown', 'New Port Richey', 'Ardmore', 'Tarpon Springs', 'Carpinteria', 'Greenwood', 'Pinellas Park', 'St. Pete Beach', 'Lutz', 'Kenner', 'Clearwater Beach', 'Palm Harbor', 'Wesley Chapel', 'Riverview', 'Dunedin', 'St Petersburg', 'St Louis', 'West Chester', 'Fishers', 'King of Prussia', 'Largo', 'Brentwood', 'Meridian', 'Cherry Hill', 'Carmel', 'Brandon', 'Wilmington', 'Goleta', 'St. Petersburg', 'Franklin', 'St. Louis', 'Metairie', 'Sparks', 'Saint Petersburg']
def tabulate_auc(dataset):
path_write = f"{directory}/{dataset}_AUC_{src}.csv"
out = open(path_write,"w")
out.write("city,NT,WT,GAT2\n")
for city in cities:
# print(city)
out.write(str(city)+",")
for mode in ["NT","WT","GAT2"]:
path_ = path + mode + "/" + str(city) + ".txt"
if mode == "NT":
num = 188
else:
num = 38
file = open(path_,"r")
lines = file.readlines()
file.close()
# print(city,mode)
# print(lines)
out.write(lines[num].split(' ')[5][:-1]+",")
out.write("\n")
out.close()
def tabulate_ap(dataset):
path_write = f"{directory}/{dataset}_AP_{src}.csv"
out = open(path_write,"w")
out.write("city,NT,WT,GAT2\n")
for city in cities:
out.write(str(city)+",")
for mode in ["NT","WT","GAT2"]:
path_ = path + mode + "/" + str(city) + ".txt"
if mode == "NT":
num = 188
else:
num = 38
file = open(path_,"r")
lines = file.readlines()
file.close()
out.write(lines[num].split(' ')[2])
out.write("\n")
out.close()
def tabulate_mrr(dataset):
path_write = f"{directory}/{dataset}_MRR_{src}.csv"
out = open(path_write,"w")
out.write("city,NT,WT,GAT2\n")
for city in cities:
out.write(str(city)+",")
for mode in ["NT","WT","GAT2"]:
path_ = path + mode + "/" + str(city) + ".txt"
if mode == "NT":
num = 189
else:
num = 39
file = open(path_,"r")
lines = file.readlines()
file.close()
out.write(lines[num].split(' ')[1][:-1]+",")
out.write("\n")
out.close()
def tabulate_rec20(dataset):
path_write = f"{directory}/{dataset}_rec20_{src}.csv"
out = open(path_write,"w")
out.write("city,NT,WT,GAT2\n")
for city in cities:
out.write(str(city)+",")
for mode in ["NT","WT","GAT2"]:
path_ = path + mode + "/" + str(city) + ".txt"
if mode == "NT":
num = 189
else:
num = 39
file = open(path_,"r")
lines = file.readlines()
file.close()
out.write(lines[num].split(' ')[11][:-1]+",")
out.write("\n")
out.close()
path = f"transfers/{source}/"
tabulate_auc(dataset)
tabulate_ap(dataset)
tabulate_mrr(dataset)
tabulate_rec20(dataset)