Building a Spam Detector
Train on labeled messages.
Your First Real Model
Time to build something useful: a spam filter. You will train a classifier on labeled messages and let it judge brand-new ones.
Start With Labeled Data
Every supervised model needs examples with answers. Here each message comes with a label of spam or ham, the friendly name for not-spam.
messages = ["win cash now", "lunch at noon?", "free prize click"]
labels = ["spam", "ham", "spam"]
print(len(messages), len(labels))All lessons in this course
- The Intuition Behind Naive Bayes
- Building a Spam Detector
- Multinomial vs Bernoulli Models
- Reading the Model's Predictions