A Gaussian naive Bayes classifier has two classes. Class A has prior , feature means and feature variances . Class B has prior , means and variances . Which class is the point assigned to?
Supervised learning, Naive Bayes
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can multiply independent one-dimensional Gaussians (add logs) and compare class scores.
Key idea
Score each class as (a constant shared by both classes is dropped) and pick the larger score.
Steps
- Naive Bayes assumes the features are independent given the class, so a class score is its log-prior plus one log-Gaussian term per feature, using . Both classes have two features, so the parts are equal and can be dropped. Logs avoid tiny products.
- Class A: feature 1 (, , ) gives . Feature 2 (, , ) gives . So the score is .
- Class B: feature 1 (, , ) gives . Feature 2 (, , ) gives . So the score is .
- has the larger score, so predict class A. The score difference is , so .
- It is a very close call (52% against 48%). Feature 1 treats both classes equally, feature 2 favours B by , and the prior favours A by , which is just enough to tip the result.
Common mistakes
- Forgetting the term. The variances differ for feature 2, so this term matters.
- Multiplying densities and rounding them early. Use logs and keep enough decimals.
- Forgetting the prior vs .
How long your answer should be
Half a page; 4 minutes.
Read this
Previous in Supervised learning: In one dimension, class 1 has density and class 2 has density (variance 4), with equal priors. Where are the Bayes decision boundaries, and which class is chosen in each region? Why is the boundary not a single point?
Next in Supervised learning: points are drawn uniformly in the unit ball in dimensions. Show that the median distance from the origin to the nearest point is . What is its value for with and , and what does it mean for k-NN?