-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_pagerank.py
32 lines (25 loc) · 867 Bytes
/
run_pagerank.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
import sys
import mga
DEFAULT_TELEPORT_PROB = 0.25
if __name__ == '__main__':
argc = len(sys.argv)
if argc == 1:
teleport_prob = DEFAULT_TELEPORT_PROB
verbose = False
elif argc == 2:
if '-v' in sys.argv[1:]:
verbose = True
teleport_prob = DEFAULT_TELEPORT_PROB
else:
verbose = False
teleport_prob = float(sys.argv[1])
elif argc == 3:
verbose = '-v' in sys.argv[1:]
teleport_prob = float(sys.argv[1])
else:
print(f'Usage: {sys.argv[0]} [<teleport_probability>] [-v]', file=sys.stderr)
sys.exit(1)
print(f'Teleport probability: {teleport_prob}')
print(f'Verbose: {verbose}')
df = mga.pagerank(base_dir='./', teleport_prob=teleport_prob, disable_progress_bar=not verbose, symmetric=True)
df.to_csv('movies_pr.csv')