Lesson 3 of 4 9 min · 154 words
Naïve Bayes
Bayes' theorem with conditionally independent features.
Naïve Bayes applies Bayes' theorem with a strong simplifying assumption: features are conditionally independent given the class. Then the likelihood factorises:
Training just means counting: estimate each class prior and each per-feature likelihood from frequencies. That makes it extremely fast and good with small data and many features.
- Gaussian NB: continuous features, each modelled as a normal distribution per class.
- Multinomial NB: word counts — the classic spam filter.
- Bernoulli NB: binary present/absent features.
The independence assumption is almost always false ('free' and 'money' co-occur in spam), yet the class ranking is often still right — Naïve Bayes classifies well even when its probabilities are poorly calibrated.
Formula to remember
k-NN prediction
Majority vote among the k nearest neighbours.
Quick check · +5 XP