MoonSay /Tutorials/Machine Learning Interview #16
Contents
  1. 01Introduction
  2. 02Bayes’ rule, part by part
  3. 03A generative classifier
  4. 04The naive assumption
  5. 05Every pixel votes
  6. 06Why it still works
  7. 07Interview follow-ups
  8. 08Common misconceptions
  9. 09Interview questions and model answers
  10. 10Summary
  11. References
Naive Bayes/Chapter 10 of 10

10Summary

  • Bayes’ rule. P(c\mid x)=P(x\mid c)P(c)/P(x), from the product rule: posterior = likelihood \times prior / evidence (center pixel off: 1\times9.9\%/31.8\%=31\% zeros).
  • A generative classifier. Learn P(c) and P(x\mid c), flip with Bayes’ rule; for classification. The likelihood of a whole image cannot be counted (2^{64} images, about 126 examples per digit).
  • The naive assumption. Features independent given the class: P(x\mid c)=\prod_dP(x_d\mid c). Training is counting, \hat\theta_{dc}=N_{dc}/N_c; Laplace smoothing (N_{dc}+1)/(N_c+2) stops zero counts from vetoing a class.
  • Every feature votes. Drop the evidence, take logs: \text{score}_c=\log\pi_c+\sum_d\log P(x_d\mid c)=w_c^\top x+b_c, a linear classifier (89.6\% of test digits, logistic regression 93.0\%).
  • Why it still works. Dependent features are counted twice; that stretches the scores but rarely changes the winner, and a decision needs only the winner. The catch: overconfident probabilities. Trust its decisions, not its probabilities.