-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprint_test_metrics.py
40 lines (32 loc) · 1.21 KB
/
print_test_metrics.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
#!/usr/bin/python3 python
"""
"""
import json
import logging
from pathlib import Path
from exp_cla_finetune import experiments as exp_cla
from exp_generation import experiments as exp_gen
if __name__ == "__main__":
NB_DECIMALS = 2
logger = logging.getLogger("res")
(fh := logging.FileHandler(Path("runs", "all_metrics.log"))).setLevel(logging.DEBUG)
(sh := logging.StreamHandler()).setLevel(logging.INFO)
logger.addHandler(fh)
logger.addHandler(sh)
logger.setLevel(logging.DEBUG)
for exp in exp_cla + exp_gen:
logger.debug(f"\n{exp.name}")
metrics = {}
for baseline in exp.baselines:
if not (baseline.run_path / "test_results.json").is_file():
continue
with open(baseline.run_path / "test_results.json") as file:
results = json.load(file)
# round results
for key, val in results.items():
if isinstance(val, float):
if "tse" in key.split("_"):
results[key] = round(val * 1000, NB_DECIMALS)
else:
results[key] = round(val, NB_DECIMALS)
logger.debug(f"{baseline.name} - {results}")