KennethTM commited on
Commit
b8c002b
1 Parent(s): 6b60f9c

Update scandeval_summary.py

Browse files
Files changed (1) hide show
  1. scandeval_summary.py +36 -9
scandeval_summary.py CHANGED
@@ -1,17 +1,44 @@
 
1
  import pandas as pd
2
 
3
- df = pd.read_json("scandeval_benchmark_results.jsonl", lines=True)
 
4
 
5
- df["total"] = [i["total"] for i in df["results"]]
 
6
 
7
- summary = []
8
- for i in df["total"]:
9
 
10
- summary_string = [f'{k.replace("test_", "")} = {round(v, 2)}' for k,v in i.items()]
11
 
12
- summary.append(", ".join(summary_string))
 
13
 
14
- df["summary"] = summary
15
 
16
- md_table = df[["task", "dataset", "summary"]].to_markdown(index=False)
17
- print(md_table)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
  import pandas as pd
3
 
4
+ #Run ScandEval on model
5
+ #scandeval --model-id KennethTM/bert-base-uncased-danish
6
 
7
+ #Format results as markdown
8
+ #python scandeval_summary.py --name scandeval_benchmark_results.jsonl
9
 
10
+ def scandeval2md(file):
11
+ df = pd.read_json(file, lines=True)
12
 
13
+ df["total"] = [i["total"] for i in df["results"]]
14
 
15
+ summary = []
16
+ for i in df["total"]:
17
 
18
+ summary_list = []
19
 
20
+ for k, v in i.items():
21
+ summary_string = ""
22
+
23
+ if "_se" in k:
24
+ summary_string += f" (±{round(v, 2)})\n"
25
+ else:
26
+ summary_string += f'{k.replace("test_", "")} = {round(v, 2)}'
27
+
28
+ summary_list.append(summary_string)
29
+
30
+ summary.append("".join(summary_list).strip())
31
+
32
+ df["summary"] = summary
33
+
34
+ md_table = df[["task", "dataset", "summary"]].rename(columns={"task": "Task", "dataset": "Dataset", "summary": "Score (±SE)"}).to_markdown(index=False)
35
+
36
+ print(md_table)
37
+
38
+ if __name__ == "__main__":
39
+
40
+ parser = argparse.ArgumentParser(description='Script for formatting ScandEval .jsonl result file as markdown to standard output')
41
+ parser.add_argument('--name', help='ScandEval .jsonl result file')
42
+ args = parser.parse_args()
43
+
44
+ scandeval2md(args.name)