-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_statistics.py
More file actions
51 lines (42 loc) · 1.52 KB
/
plot_statistics.py
File metadata and controls
51 lines (42 loc) · 1.52 KB
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
import csv
from collections import Counter
import matplotlib.pyplot as plt
FEEDBACK_FILE = 'feedback.csv'
def load_feedback(filepath):
categories = []
try:
with open(filepath, newline='', encoding='utf-8') as f:
reader = csv.reader(f)
for row in reader:
#struktura wiersza: [msg_id, label_name_ai, label_name_final, mail_sample]
if len(row) >= 3:
final_label = row[2].strip()
if final_label:
categories.append(final_label)
except FileNotFoundError:
print(f"Plik '{filepath}' nie znaleziony. Upewnij się, że feedback.csv istnieje.")
return categories
def plot_category_counts(categories):
counts = Counter(categories)
if not counts:
print("Brak danych do wyświetlenia.")
return
labels = list(counts.keys())
values = list(counts.values())
plt.figure(figsize=(10,6))
bars = plt.bar(labels, values, color='skyblue')
plt.xlabel('Kategorie')
plt.ylabel('Liczba maili')
plt.title('Statystyki przypisania kategorii maili przez asystenta')
plt.xticks(rotation=45, ha='right')
# Pokazujemy liczby nad słupkami
for bar in bars:
height = bar.get_height()
plt.text(bar.get_x() + bar.get_width()/2, height + 0.1, str(height), ha='center', va='bottom')
plt.tight_layout()
plt.show()
def main():
categories = load_feedback(FEEDBACK_FILE)
plot_category_counts(categories)
if __name__ == '__main__':
main()