-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathis_all_hate_negative_eval.py
35 lines (29 loc) · 1.39 KB
/
is_all_hate_negative_eval.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
from config import config
from data_model.toxic_comment_data import ToxicCommentData
if __name__ == '__main__':
# is_all_hate_negative?
dataset = ToxicCommentData()
label_names = dataset.get_label_names()
# To generate this file run research/is_all_hate_negative.py
content = open(config.result_file('is_all_hate_negative.csv'), 'r').readlines()
content = [line.strip().split(',') for line in content]
content = [[int(line[0]), float(line[1]), float(line[2]), float(line[3])] for line in content]
total = {}
for threshold in [0.5, 0.6, 0.7, 0.8, 0.9]:
positive_sentiment_counter = {}
for line in content:
y = line[0]
if y not in positive_sentiment_counter:
positive_sentiment_counter[y] = 0
total[y] = 0
total[y] += 1
if line[1] >= threshold:
positive_sentiment_counter[y] += 1
print(f"Threshold: {threshold}")
print('-------------------------')
positive_sentiment_counter = {k: v for k, v in
sorted(positive_sentiment_counter.items(), key=lambda item: item[1],
reverse=True)}
for key in positive_sentiment_counter:
print(f"{label_names[key]}: {positive_sentiment_counter[key]} / {total[key]}")
print('=========================')