-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbenchmark.py
77 lines (70 loc) · 2.38 KB
/
benchmark.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
64
65
66
67
68
69
70
71
72
73
74
import numpy as np
from utils.util import *
from utils.model import *
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
"--model",
default="ic",
type=str
)
parser.add_argument(
"--dataset",
default="digg",
type=str
)
parser.add_argument(
"--output",
default=1,
type=int
)
parser.add_argument(
"--repeat",
default=100,
type=int
)
parser.add_argument(
"--step",
default=10,
type=int
)
parser.add_argument(
"--beta",
default=0.9,
type=float
)
parser.add_argument(
"--gamma",
default=0.6,
type=float
)
args, _ = parser.parse_known_args()
g = load_graph("datasets/{}.edgelist".format(args.dataset))
seeds = load_seeds("datasets/{}.seed".format(args.dataset))
true_active = load_seeds("datasets/{}.spread".format(args.dataset))
print(args)
all_spread, step_spread, active_prob = None,None,None
if args.model == 'ic': # input data 1/d
all_spread, step_spread, active_prob = IC_model(args, g, seeds)
elif args.model == 'icm': # input data p=1/d, default param m(u,v)=5/(5+d_out(u)), ddl=15
all_spread, step_spread, active_prob = ICM_model(args, g, seeds)
elif args.model == 'icn': # input data p=1/d, default param q=0.9
all_spread, step_spread, active_prob = ICN_model(args, g, seeds)
elif args.model == 'ici': # input data p=1/d, default param beta=0.9, gamma=0.6
all_spread, step_spread, active_prob = ICI_model(args, g, seeds,beta=args.beta,gamma=args.gamma)
elif args.model == 'lt': # input data p=1/d
all_spread, step_spread, active_prob = LT_model(args, g, seeds)
elif args.model == 'ftm': # input data p=1/d
all_spread, step_spread, active_prob = FTM_model(args, g, seeds)
elif args.model == 'ltc': # input data p=1/d, default param lambda_a = 0.3 lambda_b = 0.1 mu_a = 0.001 mu_b = 0.001
all_spread, step_spread, active_prob = LTC_model(args, g, seeds)
else:
exit("Unsupported model")
print("--------------------Results--------------------------")
print("overall spreads:")
print(all_spread)
print("step spreads:")
print(step_spread)
print("activation probability of each user:")
print(active_prob)