Naive Bayes
Machine Learning · Intermediate
Definition
Naive Bayes applies Bayes' theorem assuming features are independent given the class.
Fast and strong for text classification like spam detection.
Diagram
Flowchart
Example: Bayes numerical
p_spam, p_word_spam, p_word = 0.3, 0.8, 0.4
print(round(p_spam * p_word_spam / p_word, 2))Output: 0.6
Complexity
Training O(n·d)
Key points
- Use Laplace smoothing for unseen words
- Works well with little data
Interview questions
Why 'naive'?
It assumes all features are independent, which is rarely true.