-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
19 lines (19 loc) · 922 Bytes
/
Copy pathutils.py
File metadata and controls
19 lines (19 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def test_detector(detector):
"""Test thử model với vài email mẫu"""
test_emails = [
"Meeting scheduled for tomorrow at 10 AM.", # ham
"URGENT: Your account has been compromised. Click the link below to secure it immediately.", # spam
"Here are the quarterly sales reports.", # ham
"Limited-time offer! Buy now and get 50% off.", # spam
"Congratulations! You've won a free lottery, click here to claim.", # spam
"Can you send me the project files?", # ham
]
print("\nTesting với email mẫu:")
print("-" * 60)
predictions = detector.predict(test_emails)
probas = detector.predict_proba(test_emails)
for i, email in enumerate(test_emails):
spam_prob = probas[i][1] * 100 # Xác suất spam
print(f"'{email[:45]}...'")
print(f" → Predicted: {predictions[i]} (spam: {spam_prob:.1f}%)")
print()