-
Notifications
You must be signed in to change notification settings - Fork 5
/
batch_ranking.py
63 lines (53 loc) · 2.34 KB
/
batch_ranking.py
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
################################################################
# System's dependencies
################################################################
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
import os
import sys
import time
import argparse
################################################################
# Local dependencies
################################################################
from org.gesis.lib import rank
from org.gesis.lib import paper
################################################################
# Constants
################################################################
DATASETS = ['aps','hate','blogs','wikipedia']
BETA = 0.05 #beta
MODELS = ["Random","DPA","DH","DPAH"]
ALLKIND = ['empirical'] + MODELS
################################################################
# Main
################################################################
def run(path, dataset):
print(path, dataset)
# create ranking measures for each network
_ = rank.horizontal_inequalities_parallel(path, dataset)
# create summary file
root = path.split('/')[0] # resuts
kind = path.split('/')[1] # synthetic, fit, empirical
# @TODO: make it work for fit and empirical nets
if kind == 'synthetic':
# only works for synthetic
models = [path.split('/')[2]]
print(root, kind, models)
df_rank = paper.load_rank_synthetic_all_models(os.path.join(root,kind), models, BETA, True)
print(df_rank.head())
#df_rank = paper.load_rank_all_models(os.path.join(root,'fit'), models, SMOOTH, DATASETS)
#df_rank = paper.load_rank(os.path.join(root,'empirical'), df_network_metadata_empirical, SMOOTH, DATASETS, ALLKIND)
print(df_rank.shape)
################################################################
# Main
################################################################
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--path", help="directory where <dataset>/*.csv files are.", type=str, required=True)
parser.add_argument("--dataset", help="datasets ({}).".format(",".join(DATASETS)),
type=str, default=None)
args = parser.parse_args()
start_time = time.time()
run(args.path, args.dataset)
print("--- %s seconds ---" % (time.time() - start_time))