Naive Bayes
Supervised · Classification Naive Bayes uses probability. For each clue (such as a word in an email), it asks: how often does this clue appear in each category? It combines all the clues using Bayes' theorem and picks the most likely category. It's called "naive" because it assumes each clue is independent of the others, which isn't quite true, yet it works surprisingly well.
Everyday analogy
A doctor guessing flu: fever makes flu more likely, a cough makes it even more likely, body ache more still. Each symptom adds evidence, and together they point to an answer.
Example
Used for: email spam filters, sentiment analysis of reviews, sorting news into topics, tagging documents.
How often words appear in each kind of email
| Word | Found in spam emails | Found in normal emails |
|---|---|---|
| "FREE" | 30% | 1% |
| "WIN" | 20% | 0.5% |
| "meeting" | 1% | 15% |
| "invoice" | 3% | 8% |
How it works, step by step
- From labelled emails, count how often each word appears in spam and in normal emails.
- Also note how common spam is overall (the starting probability).
- For a new email, look up the probability of each of its words in each category.
- Multiply these clues together with the starting probability to get a score for "spam" and for "not spam".
- Pick the category with the higher score.
Worked example
New email: "WIN a FREE phone". "WIN" is 40 times more common in spam, and "FREE" is 30 times more common. Together they push the spam score far above the normal score, so the email goes to the spam folder. An email saying "meeting invoice attached" would score as normal.
✓ Good for
- Extremely fast, even on huge amounts of text
- Works well with little training data
- Simple to build and update
⚠ Watch out for
- Assumes clues are independent, which is rarely true
- Its probability numbers can be overconfident
- Outperformed by modern models on complex language
Try it yourself
About 10 minCount spam words
- Look at 5 spam and 5 normal emails in your inbox.
- Count how often words like free, winner, meeting appear in each group.
- Guess whether a new email is spam from its words.
What you should see: Naive Bayes is word-counting plus probability.
Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.