-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreproduce_nces2.py
40 lines (34 loc) · 1.89 KB
/
reproduce_nces2.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
from argparse import Namespace
import argparse
from helper_reproduce_nces2 import *
import os
os.environ["TOKENIZERS_PARALLELISM"] = "false"
def str2bool(v):
if isinstance(v, bool):
return v
elif v.lower() in ['t', 'true', 'y', 'yes', '1']:
return True
elif v.lower() in ['f', 'false', 'n', 'no', '0']:
return False
else:
raise ValueError('Invalid boolean value.')
if __name__ == '__main__':
with open("settings.json") as setting:
nces_args = json.load(setting)
nces_args = Namespace(**nces_args)
parser = argparse.ArgumentParser()
parser.add_argument('--kbs', type=str, nargs='+', default=['carcinogenesis'], choices=['carcinogenesis', 'mutagenesis', 'semantic_bible', 'vicodi'], help='Knowledge base name')
parser.add_argument('--kb_emb_model', type=str, default="ConEx", help='KB embedding model')
parser.add_argument('--ensemble', type=str2bool, default=True, help='Whether to also evaluate ensemble models')
parser.add_argument('--save_results', type=str2bool, default=False, help='Whether to save the evaluation results')
parser.add_argument('--verbose', type=str2bool, default=False, help='Whether to print the target and predicted class expressions')
args = parser.parse_args()
nces_args.kb_emb_model = args.kb_emb_model
for kb in args.kbs:
print()
evaluate_nces(kb_name=kb, num_inds=[32, 64, 128], args=nces_args, save_results=args.save_results, verbose=args.verbose) #kb_name, proj_dims, emb_dim, args, save_results=False, verbose=False
print()
if args.ensemble:
print("*"*25 + " Evaluating ensemble model " + "*"*25)
evaluate_ensemble(kb_name=kb, args=nces_args, save_results=args.save_results, verbose=args.verbose) # kb_name, args, emb_dim, save_results=False, verbose=False
print("*"*25 + " Evaluating ensemble model " + "*"*25+"\n")