-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathtest_ensemble_construction.py
More file actions
38 lines (36 loc) · 1.36 KB
/
test_ensemble_construction.py
File metadata and controls
38 lines (36 loc) · 1.36 KB
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
from dicee.executer import Execute
from dicee.knowledge_graph_embeddings import KGE
import pytest
import os
from dicee.config import Namespace
class TestEnsembleConstruction:
@pytest.mark.filterwarnings('ignore::UserWarning')
def test_k_vs_all(self):
args = Namespace()
args.model = 'QMult'
args.scoring_technique = 'KvsAll'
args.optim = 'Adam'
args.dataset_dir = 'KGs/UMLS'
args.num_epochs = 10
args.batch_size = 1024
args.lr = 0.1
args.embedding_dim = 32
args.input_dropout_rate = 0.0
args.hidden_dropout_rate = 0.0
args.feature_map_dropout_rate = 0.0
args.eval_model = 'train_val_test'
args.read_only_few = None
args.sample_triples_ratio = None
args.num_folds_for_cv = None
args.save_model_at_every_epoch = 3
args.normalization = 'LayerNorm'
args.backend = 'pandas'
args.trainer = 'torchCPUTrainer'
result = Execute(args).start()
assert 0.71 >= result['Train']['H@1'] >= 0.03
assert 0.71 >= result['Val']['H@1'] >= 0.03
assert 0.71 >= result['Test']['H@1'] >= 0.03
assert os.path.isdir(result['path_experiment_folder'])
# (1) Load single model
KGE(path=result['path_experiment_folder'])
KGE(path=result['path_experiment_folder'], construct_ensemble=True)