-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_result.py
68 lines (60 loc) · 1.74 KB
/
print_result.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
60
61
62
63
64
65
66
67
68
import pandas as pd
from fire import Fire
def math_result(filename: str, level: int = 0, label_column_name="auto_label"):
"""level: 0, 1, 2, 3"""
print(filename)
df = pd.read_csv(filename)
if level == 0:
df = df[~df["category"].isin(["invalid", "original"])]
mean = df[label_column_name].mean()
print(mean)
return
if level == 1:
key = "aspect"
elif level == 2:
key = "target"
elif level == 3:
key = "dimension"
elif level == 4:
key = "category"
mean = df.groupby(key)[label_column_name].mean()
print(mean)
def code_result(filename: str, level: int = 0, label_column_name="auto_label"):
"""level: 0, 1, 2, 3"""
print(filename)
df = pd.read_csv(filename)
if df.auto_label.dtype != bool:
df["auto_label"] = df["auto_label"] == "True"
if level == 0:
df = df[~df["category"].isin(["invalid", "original"])]
mean = df[label_column_name].mean()
print(mean)
return
if level == 1:
key = "aspect"
elif level == 2:
key = "target"
elif level == 3:
key = "dimension"
elif level == 4:
key = "category"
mean = df.groupby(key)[label_column_name].mean()
print(mean)
def autoeval_result(filename: str):
"""level: 0, 1, 2, 3"""
print(filename)
df = pd.read_csv(filename)
df = df[~df["category"].isin(["invalid", "original"])]
results = []
for (
a,
h,
) in zip(df["auto_label"], df["human_label"]):
a = str(a).lower()
h = str(h).lower()
if str(a) == "nan" or str(h) == "nan":
continue
results.append(a == h)
print(sum(results) / len(results))
if __name__ == "__main__":
Fire()