Chap4 Naive Bayes
Chap4 Naive Bayes
Bayesian Classifiers
Bayes Classifier
2
Using Bayes Theorem for Classification
• Approach:
– compute posterior probability P(Y | X1, X2, …, Xd) using
the Bayes theorem
P ( X 1 X 2 X d | Y ) P (Y )
P (Y | X 1 X 2 X n )
P( X 1X 2 X d )
4
Example Data
Given a Test Record:
X ( Refund No, Divorced, Income 120K)
c c c
Tid Refund Marital
Status
Taxable
Income Evade • We need to estimate
1 Yes Single 125K No P(Evade = Yes | X) and P(Evade = No | X)
2 No Married 100K No
3 No Single 70K No
4 Yes Married 120K No In the following we will replace
5 No Divorced 95K Yes
Evade = Yes by Yes, and
6 No Married 60K No
7 Yes Divorced 220K No Evade = No by No
8 No Single 85K Yes
9 No Married 75K No
10 No Single 90K Yes
10
Example Data
Given a Test Record:
X ( Refund No, Divorced, Income 120K)
c c c
Tid Refund Marital Taxable
Status Income Evade
6
Conditional Independence
8
Naïve Bayes on Example Data
Given a Test Record:
X ( Refund No, Divorced, Income 120K)
c c c
Tid Refund Marital Taxable
Status Income Evade P(X | Yes) =
1 Yes Single 125K No
P(Refund = No | Yes) x
2 No Married 100K No
3 No Single 70K No
P(Divorced | Yes) x
4 Yes Married 120K No P(Income = 120K | Yes)
5 No Divorced 95K Yes
6 No Married 60K No
7 Yes Divorced 220K No
P(X | No) =
8 No Single 85K Yes P(Refund = No | No) x
9 No Married 75K No
P(Divorced | No) x
10 No Single 90K Yes
10
P(Refund=Yes|Yes)=0
10
Estimate Probabilities from Data
11
1
( 120 110 ) 2
12
Example of Naïve Bayes Classifier
Given a Test Record:
13
14
Issues with Naïve Bayes Classifier
Given a Test Record:
X = (Married)
15
16
Issues with Naïve Bayes Classifier
17
Name Give Birth Can Fly Live in Water Have Legs Class
human yes no no yes mammals
A: attributes
python no no no no non-mammals M: mammals
salmon no no yes no non-mammals
whale yes no yes no mammals N: non-mammals
frog no no sometimes yes non-mammals
komodo no no no yes non-mammals
6 6 2 2
bat yes yes no yes mammals P ( A | M ) 0.06
pigeon
cat
no
yes
yes
no
no
no
yes
yes
non-mammals
mammals
7 7 7 7
leopard shark yes no yes no non-mammals 1 10 3 4
turtle no no sometimes yes non-mammals P ( A | N ) 0.0042
penguin no no sometimes yes non-mammals 13 13 13 13
porcupine yes no no yes mammals
eel no no yes no non-mammals 7
salamander no no sometimes yes non-mammals P ( A | M ) P ( M ) 0.06 0.021
gila monster no no no yes non-mammals 20
platypus no no no yes mammals
13
owl
dolphin
no
yes
yes
no
no
yes
yes
no
non-mammals
mammals
P ( A | N ) P( N ) 0.004 0.0027
eagle no yes no yes non-mammals 20
18
Naïve Bayes (Summary)
19
Naïve Bayes
20
Bayesian Belief Networks
21
Conditional Independence
D is parent of C
A is child of C
B is descendant of D
D is ancestor of A
22
Conditional Independence
23
Probability Tables
24
Example of Bayesian Belief Network
Exercise Diet
Blood
Chest Pain
Pressure
25
26