-
Notifications
You must be signed in to change notification settings - Fork 4
/
collate.py
59 lines (44 loc) · 1.67 KB
/
collate.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
import logging
import os
import click
import pandas as pd
import pykeen_report.utils
HERE = os.path.dirname(__file__)
RESULTS = os.path.join(HERE, 'results')
SUMMARY_DIRECTORY = os.path.join(HERE, 'summary')
os.makedirs(SUMMARY_DIRECTORY, exist_ok=True)
# Shut up about mapping triples, lol
logging.getLogger('pykeen.triples.triples_factory').setLevel(logging.ERROR)
COLLATION_PATH = os.path.join(SUMMARY_DIRECTORY, 'results.tsv')
HPO_RUNS_RESULTS_PATH = os.path.join(SUMMARY_DIRECTORY, 'hpo_run_results.tsv')
CHECKLIST_TSV_PATH = os.path.join(SUMMARY_DIRECTORY, 'checklist.tsv')
CHECKLIST_LATEX_PATH = os.path.join(SUMMARY_DIRECTORY, 'checklist.tex')
def read_collation() -> pd.DataFrame:
"""Read the collated benchmarking results."""
return pykeen_report.utils.read_ablation_collation(COLLATION_PATH)
def collate(key: str) -> pd.DataFrame:
"""Collate all results from replicates of the best HPO pipelines (for a given metric)."""
return pykeen_report.utils.collate_ablation(
results_directory=RESULTS,
output_path=COLLATION_PATH,
key=key,
)
def collate_hpo_experiments() -> pd.DataFrame:
"""Collate all results from HPO pipelines."""
return pykeen_report.utils.collate_hpo_experiments(
results_directory=RESULTS,
output_path=HPO_RUNS_RESULTS_PATH,
)
@click.command()
def main():
"""Collate the hits@10 metrics and output."""
collate_hpo_experiments()
df = collate('hits@10')
pykeen_report.utils.make_checklist_df(
df=df,
output_csv_path=CHECKLIST_TSV_PATH,
output_latex_path=CHECKLIST_LATEX_PATH,
)
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
main()