Skip to content

Commit ef77bac

Browse files
committed
Added more testing in voting
1 parent 5a2739f commit ef77bac

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

spam_detector_ai/prediction/predict.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,41 @@ def __init__(self):
105105
def is_spam(self, message_):
106106
# Count the number of spam predictions
107107
spam_votes = sum(detector.is_spam(message_) for detector in self.detectors)
108-
print(f"spam_votes: {[detector.is_spam(message_) for detector in self.detectors]}")
109108
# Count the number of ham (not spam) predictions
110109
ham_votes = len(self.detectors) - spam_votes
111110
# Majority voting: if the majority of detectors say it's a spam, return True, otherwise False
111+
print(f"Votes: {[detector.is_spam(message_) for detector in self.detectors]}, spam: {spam_votes}, "
112+
f"ham: {ham_votes}")
112113
return spam_votes > ham_votes
113114

114115

115116
if __name__ == "__main__":
116117
voting_detector = VotingSpamDetector()
117118

118-
message = "Hi John, I hope you are doing well. I wanted to follow up on the meeting we had last week. When can we schedule the next meeting? Best, Jane"
119-
print("Voting -> Is spam:", voting_detector.is_spam(message))
119+
message_1 = "Hello!"
120+
print("Message 1 -> Is spam:", voting_detector.is_spam(message_1), f"Expected: False")
121+
message_2 = (f"Hi, I noticed your website hasn't embraced AI capabilities yet. Would you be interested in a "
122+
f"suggestion I have?")
123+
print("Message 2 -> Is spam:", voting_detector.is_spam(message_2), f"Expected: True")
124+
message_3 = (f"Developed by a Construction Specific CPA Firm, TimeSuite is the worlds most advanced Construction "
125+
f"Software. TimeSuite is next generation. Advanced because it’s intuitive, comprehensive and "
126+
f"dynamic. Advanced because it’s has a relational architecture (no modular subsystems/no modules). "
127+
f"Web, desktop and mobile interfaces to a single database. One system, 3 comprehensive interfaces. "
128+
f"Project Management, Accounting, Scheduling, Estimating, On-Screen Take Off, PDF Viewer, "
129+
f"CAD Drawing Layering, Geo Timecards, CRM, Task Management, Resource Management, Banking System "
130+
f"Integration, Text Messaging, Email, Calendar, Form Creation, Property Management, "
131+
f"RFQs/Bid Packages, Outlook and Google email and calendar integrations and more. Fully automated "
132+
f"percentage of completion method of accounting with a full job schedule that always ties to the "
133+
f"income statement. Gain access to a live fully functional demo at TimeSuite.com.")
134+
print("Message 3 -> Is spam:", voting_detector.is_spam(message_3), f"Expected: True")
135+
message_4 = (f"Bonsoir mwen se Haitian mwen bezwen pran seminaire sou profesyon siw fè please retounenm poum pran "
136+
f"kontak avem mesi.")
137+
print("Message 4 -> Is spam:", voting_detector.is_spam(message_4), f"Expected: False")
138+
message_5 = (f"subject: Want a birthday shoot for my little brother and I. I am one of Jeff and Germina's"
139+
f"friends and Germina' friends they give me your website and our birthday is on the 21st of "
140+
f"February please lemme know.")
141+
print("Message 5 -> Is spam:", voting_detector.is_spam(message_5), f"Expected: False")
142+
message_6 = f"Hello, I went to your blog and I really like your article. Thanks for doing such a great job."
143+
print("Message 6 -> Is spam:", voting_detector.is_spam(message_6), f"Expected: False")
144+
message_7 = f"Hi, when I tried browsing through your article, I found a few broken links. Please fix them."
145+
print("Message 7 -> Is spam:", voting_detector.is_spam(message_7), f"Expected: False")

0 commit comments

Comments
 (0)