-
Notifications
You must be signed in to change notification settings - Fork 2
/
make_md.py
49 lines (38 loc) · 1.28 KB
/
make_md.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
import pandas as pd
from glob import glob
from tqdm import tqdm
import jsonlines
import os
def main():
files = list(glob("data/**/*.json", recursive=True))
total = []
for file in tqdm(files):
with jsonlines.open(file) as fin:
for line in fin:
if "score" not in line:
continue
dirname = os.path.dirname(file).replace("data/", "")
filename = os.path.basename(file).replace(".json", "")
total.append(
{"model": dirname, "testset": filename, "score": line["score"]}
)
df = pd.DataFrame(total)
df = (
df.groupby(["model", "testset"])
.agg({"score": ["mean", "std", "count"]})
.reset_index()
)
df.columns = ["-".join(c) if c[1] else c[0] for c in df.columns]
print(df)
with open("all_results.md", "w") as fout:
for testset in df.testset.unique():
subset = (
df[df.testset == testset]
.drop("testset", axis=1)
.sort_values("score-mean", ascending=False)
)
fout.write(f"## {testset}\n\n")
fout.write(subset.to_markdown(index=False))
fout.write("\n\n")
if __name__ == "__main__":
main()