1
Naïve Bayes --- Recap
• Revisit
• Which is equal to
4
Naïve Bayes
• For continuous Xi
• Generative training
• Prediction
Naïve Bayes
• Example: Continuous-valued Features
– Temperature is naturally of continuous value.
Yes: 25.2, 19.3, 18.5, 21.7, 20.1, 24.3, 22.8, 23.1, 19.8
No: 27.3, 30.1, 17.4, 29.5, 15.1
– Estimate mean and variance for each class
1 N 1 N Yes 21.64 , Yes 2.35
xn , ( xn )2
2
No 23.88 , No 7.09
N n1 N n1
7
Bayes Formula
Generative Model
• Color
• Size
• Texture
• Weight
• …
Numerical Stability
• It is often the case that machine learning
algorithms need to work with very small
numbers
– Imagine computing the probability of 2000
independent coin flips
– MATLAB thinks that (0.5)2000 = 0
Underflow Prevention
• Multiplying lots of probabilities
floating-point underflow.