πŸ“§ Classification Β· NaΓ―ve Bayes

Spam or Not Spam?

Label emails, build a word-frequency table, and train a real NaΓ―ve Bayes classifier β€” the same algorithm that powers Gmail's spam filter!

πŸ“§ Label Emails
πŸ“Š Word Frequencies
πŸ§ͺ Test Your Filter
πŸ“ˆ Accuracy Report
πŸ† Badge

How NaΓ―ve Bayes Works

πŸ“§

Collect Examples

Label emails as Spam or Ham (not-spam). These become your training data.

πŸ”’

Count Word Frequencies

Count how often each word appears in spam vs ham emails. "Free" appears more in spam!

πŸ“Š

Calculate Probabilities

P(spam|email) = P(word1|spam) Γ— P(word2|spam) Γ— … Γ— P(spam). Bayes' theorem!

βš–οΈ

Classify

Whichever probability is higher β€” spam or ham β€” wins. That's the prediction!

πŸ“§
Wizzy the AI Tutor
Welcome to the Spam Lab! πŸŽ‰ Read each email carefully and label it Spam πŸ”΄ (junk, suspicious, too good to be true) or Ham 🟒 (real, useful email). Your labels teach the NaΓ―ve Bayes model what spam looks like!

Step 1 β€” Label the Training Emails

0 / 12 labelled
πŸ“§
Wizzy the AI Tutor
Your labels taught the model something! Now look at which words appear most in spam vs ham. Words like "free", "winner", "urgent" are far more common in spam. The model uses these frequencies to calculate the probability that a new email is spam!

Step 2 β€” Word Frequency Analysis

πŸ”΄ Top Spam Words

🟒 Top Ham Words

πŸ“§
Wizzy the AI Tutor
Time to test your trained spam filter! πŸ§ͺ For each new email, the model calculates P(spam) and P(ham) and picks the higher one. Watch the probability bars and see which words pushed the decision. Can the filter catch all the spam?

Step 3 β€” Test the Spam Filter

0 / 8 tested
What do YOU think?
πŸ€”
Classify an email to see probabilities
πŸ”΄ Spam
β€”
🟒 Ham
β€”
Key evidence words
Classify an email first

πŸ§ͺ Test Results

Tested0 / 8
Correct0
Wrong0
Your accuracyβ€”
πŸ“§
Wizzy the AI Tutor
Look at the full accuracy report! πŸ“ˆ Precision = how many spam predictions were actually spam. Recall = how many real spams did we catch. F1 score combines both. Real email filters aim for 99%+ β€” but they use millions of emails for training!

Accuracy Report

β€”
Accuracy
β€”
Precision
β€”
Recall
β€”
F1 Score
πŸ“§
Wizzy the AI Tutor
🎊 You've just built a real NaΓ―ve Bayes spam classifier β€” the same algorithm behind Gmail, Outlook, and Yahoo Mail! You understand training data, word frequencies, probability, and evaluation metrics. That's real machine learning engineering!
πŸ“§

Spam Hunter Badge!

You trained a NaΓ―ve Bayes classifier from scratch and evaluated its performance!

πŸ“§ WhizzStep AI Lab
This certifies that
Student Name
has built and tested a NaΓ―ve Bayes Spam Classifier
Spam Hunter
NaΓ―ve Bayes Expert
ML Engineer
Accuracy: β€” Β· whizzstep.in

Key Concepts Mastered

NaΓ―ve Bayes

🎲 The Algorithm

Assumes each word contributes independently to spam probability. "NaΓ―ve" because real words aren't independent β€” but it still works great!

Prior Probability

πŸ“Š Base Rate

P(spam) = fraction of spam in training data. If 6 of 12 emails are spam, P(spam) = 0.5.

Laplace Smoothing

βž• Handling Zeros

What if a word never appeared in training? We add +1 to every count so probabilities are never zero.

Precision vs Recall

βš–οΈ The Trade-off

High precision = few false alarms. High recall = catch all spam. F1 score balances both!

Log Probabilities

πŸ”’ Avoiding Underflow

Multiplying many tiny probabilities gives near-zero. We add log probabilities instead β€” same result, no underflow!

Real World

🌍 Where It's Used

Gmail, Outlook, Yahoo Mail, and almost every email service uses NaΓ―ve Bayes as a first-pass spam filter.