-
Notifications
You must be signed in to change notification settings - Fork 3
/
eval.py
executable file
·100 lines (91 loc) · 3.51 KB
/
eval.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
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
from context import gvnr
import sys
import gvnr.baselines
import argparse
import logging
logger = logging.getLogger()
list_methods_graph_text = [
"binary",
"tfidf",
"svd",
"deepwalk_svd",
"netmf_svd",
"tadw",
"gvnrt"
]
list_methods_graph_only = [
"netmf",
"netmf_small",
"deepwalk",
"glove",
"gvnr_no_filter",
"gvnr"
]
list_dataset_graph_text = [
"cora",
"citeseer"
]
list_dataset_graph_only = [
"aminer",
"wikipedia",
"ppi",
"blogcatalog"
]
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--save",
help="If specified, saves the computed embeddings (csv format) in the 'gnvr/embeddings/' directory.",
action="store_true")
parser.add_argument("-m", "--method", type=str, help=f"Method to be used. Each of them if not specified."
f" Available options are (graph+text) {list_methods_graph_text}"
f" and (graph only) {list_methods_graph_only}")
parser.add_argument("-d", "--dataset", type=str, help=f"Dataset to work with. Each of them if not specified."
f" Available options are (graph+text) {list_dataset_graph_text}"
f" and (graph only) {list_dataset_graph_only}.")
args = parser.parse_args()
if args.method is not None:
if args.method in list_methods_graph_text:
if args.dataset is not None:
if args.dataset in list_dataset_graph_text:
baselines = {args.dataset: [args.method]}
gvnr.baselines.run(baselines, save=args.save)
elif args.dataset in list_dataset_graph_only:
logger.error(f"Dataset {args.dataset} (graph only) is not compatible with method {args.method} (graph+text) !")
sys.exit(0)
else:
logger.error(f"Unknown dataset {args.dataset} !")
sys.exit(0)
else:
baselines = {d: [args.method] for d in list_dataset_graph_text}
gvnr.baselines.run(baselines, save=args.save)
elif args.method in list_methods_graph_only:
if args.dataset is not None:
if args.dataset in list_dataset_graph_only+list_dataset_graph_text:
baselines = {args.dataset: [args.method]}
gvnr.baselines.run(baselines, save=args.save)
else:
logger.error(f"Unknown dataset {args.dataset} !")
sys.exit(0)
else:
baselines = {d: [args.method] for d in list_dataset_graph_only+list_dataset_graph_text}
gvnr.baselines.run(baselines, save=args.save)
else:
logger.error(f"Unknown method {args.method} !")
sys.exit(0)
else:
baselines = {
"cora": list_methods_graph_only+list_methods_graph_text,
"citeseer": list_methods_graph_only+list_methods_graph_text,
"aminer": list_methods_graph_only,
"wikipedia": list_methods_graph_only,
"ppi": list_methods_graph_only,
"blogcatalog": list_methods_graph_only
}
if args.dataset is not None:
if args.dataset in list_dataset_graph_only+list_dataset_graph_text:
baselines = {args.dataset: baselines[args.dataset]}
gvnr.baselines.run(baselines, save=args.save)
else:
logger.error(f"Unknown dataset {args.dataset} !")
sys.exit(0)
else:
gvnr.baselines.run(baselines, save=args.save)