-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_main_graph_results.py
44 lines (39 loc) · 1.22 KB
/
print_main_graph_results.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
import json, argparse
import pathlib as pl
from typing import Literal
import pandas as pd
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--run", type=str)
args = parser.parse_args()
with open(pl.Path(args.run) / "metrics.json") as f:
metrics_dict = json.load(f)
METRICS_TO_PRINT = [
"node_f1",
"node_precision",
"node_recall",
"edge_f1",
"edge_precision",
"edge_recall",
"weighted_edge_f1",
"weighted_edge_precision",
"weighted_edge_recall",
]
def get_value(metric: str, pipeline: Literal["coref", "nocoref"]) -> float:
pipeline_name = "pipeline" if pipeline == "coref" else "pipeline_nocoref"
return round(
metrics_dict[f"MEAN_{pipeline_name}.{metric}"]["values"][0] * 100, 2
)
df = pd.DataFrame(
{
"Metric": METRICS_TO_PRINT,
"w/ coreference": [
get_value(metric, "coref") for metric in METRICS_TO_PRINT
],
"w/o coreference": [
get_value(metric, "nocoref") for metric in METRICS_TO_PRINT
],
}
)
df = df.set_index("Metric")
print(df)