-
Notifications
You must be signed in to change notification settings - Fork 0
/
marking.py
71 lines (48 loc) · 1.58 KB
/
marking.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
69
70
71
import pandas as pd
import numpy as np
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score
import single_infer
import multi_infer
import inferTest_infer
PATH = "./test.txt"
RESULT_PATH="graph.txt"
DIFF_PATH="diff.txt"
df = pd.read_csv(PATH, sep='\t')
#print(type(df['악플']))
#print(df['악플'])
#print(df['악플'].tolist())
y_true = df['악플'].tolist()
multi_pred = []
single_pred = []
inferTest_pred = []
diff = open(DIFF_PATH, 'a')
result = open(RESULT_PATH, 'a')
for idx ,i in enumerate(df['내용']):
mul = multi_infer.judge(i)
sin = single_infer.judge(i)
inf = inferTest_infer.judge(i)
multi_pred.append(mul)
single_pred.append(sin)
inferTest_pred.append(inf)
if mul != sin or mul != inf or sin != inf:
print(f'mul : {mul}, sin : {sin}, inf : {inf}, pred : {y_true[idx]}, sentence : {i}', file=diff)
print(idx)
#pass
acc = accuracy_score(y_true, multi_pred)
prec = precision_score(y_true, multi_pred)
rec = recall_score(y_true, multi_pred)
f1 = f1_score(y_true, multi_pred)
print("MULTI: ",acc, prec, rec, f1, file=result)
acc = accuracy_score(y_true, single_pred)
prec = precision_score(y_true, single_pred)
rec = recall_score(y_true, single_pred)
f1 = f1_score(y_true, single_pred)
print("SINGLE: ",acc, prec, rec, f1, file=result)
acc = accuracy_score(y_true, inferTest_pred)
prec = precision_score(y_true, inferTest_pred)
rec = recall_score(y_true, inferTest_pred)
f1 = f1_score(y_true, inferTest_pred)
print("INFERTEST: ",acc, prec, rec, f1, file=result)
diff.close()
result.close()
#multi_infer.infer()