-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_classifier.py
More file actions
executable file
·113 lines (93 loc) · 3.38 KB
/
test_classifier.py
File metadata and controls
executable file
·113 lines (93 loc) · 3.38 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python3
"""
Test script for expense classifier.
Tests both EU/Ireland-specific and general expense titles.
"""
from expense_classifier import classify_expense
def test_classifier():
"""Test the expense classifier with various examples."""
print("="*70)
print("EXPENSE CLASSIFIER TEST")
print("="*70)
print("\nTesting classification with various expense titles...")
print("-"*70)
# Test cases - mix of general and EU/Ireland specific
test_cases = [
# Food
("McDonald", "food"),
("Starbucks coffee", "food"),
("Dinner at Supermac's", "food"),
("Tesco meal deal", "food"),
("Dunnes Stores cafe", "food"),
("Deliveroo order", "food"),
("Just Eat", "food"),
# Travel
("Uber ride", "travel"),
("Luas ticket", "travel"),
("DART fare", "travel"),
("Dublin Bus", "travel"),
("Flight to London", "travel"),
("Aer Lingus", "travel"),
("Ryanair flight", "travel"),
("Parking at airport", "travel"),
("Taxi to city centre", "travel"),
# Shopping
("Tesco shopping", "shopping"),
("Dunnes Stores", "shopping"),
("SuperValu groceries", "shopping"),
("Aldi", "shopping"),
("Lidl", "shopping"),
("Penneys", "shopping"),
("Primark", "shopping"),
("Boots pharmacy", "shopping"),
("Amazon order", "shopping"),
# Entertainment
("Movie tickets", "entertainment"),
("Concert at 3Arena", "entertainment"),
("Croke Park match", "entertainment"),
("Aviva Stadium", "entertainment"),
("Cinema", "entertainment"),
("Pub drinks", "entertainment"),
# Utilities
("ESB electricity bill", "utilities"),
("Eir internet", "utilities"),
("Vodafone phone bill", "utilities"),
("Netflix subscription", "utilities"),
("Spotify", "utilities"),
("Sky TV", "utilities"),
("Virgin Media", "utilities"),
# Other
("Gym membership", "other"),
("Doctor visit", "other"),
("Haircut", "other"),
]
correct = 0
total = len(test_cases)
print(f"{'Expense Title':<40} {'Expected':<15} {'Predicted':<15} {'Status'}")
print("-"*70)
for title, expected in test_cases:
predicted = classify_expense(title)
status = "✓" if predicted == expected else "✗"
if predicted == expected:
correct += 1
print(f"{title:<40} {expected:<15} {predicted:<15} {status}")
print("-"*70)
accuracy = (correct / total) * 100
print(f"\nResults: {correct}/{total} correct ({accuracy:.1f}% accuracy)")
print("="*70)
return accuracy
if __name__ == "__main__":
try:
accuracy = test_classifier()
if accuracy >= 90:
print("\n🎉 Excellent! Classifier is working very well!")
elif accuracy >= 80:
print("\n✅ Good! Classifier is working well.")
elif accuracy >= 70:
print("\n⚠️ Acceptable, but could be better.")
else:
print("\n❌ Poor accuracy. Check classifier implementation.")
except Exception as e:
print(f"\n❌ Error testing classifier: {e}")
import traceback
traceback.print_exc()