NaiveBayes Algorithm
NaiveBayes Algorithm
P(X / Ci ) = ∏ P ( x k /C i )
k =1
= argmax {P(X/C)*P(C)}
n
C1: YES
n
argmax{∏ P ( x k /C i )∗P(C) }}
k =1
= P(x1 = College / C1=Yes) * P(x2 = Middle_Aged / C1=Yes) * P(x3 = Female / C1=Yes) * P(C1=Yes)
C2: No
n
argmax{∏ P ( x k /C i )∗P(C) }}
k =1
= P(x1 = College / C2=NO) * P(x2 = Middle_Aged / C2=NO) * P(x3 = Female / C2=NO) * P(C2=NO)
Argmax {0.03, 0.028 } = 0.03 comes from the first class so we can say that the test
instances’s class label should be YES
= P(x1 = College / C2=NO) * P(x2 = Middle_Aged / C2=NO) * P(x3 = Female / C2=NO) * P(C2=NO)
YES (Age): The age of the people who were accepted for the company:
60
40
40
60
42
Mean()=48.4
Stdev()=10.62
2
−1 44−48.4
1 ( )
P(x2= 44/C1=YES) = e 2 10.62
= 0.0344
√2 π ( 2.57 ) 2
???? = 0.0344
P(C1=YES/Xtest) = P(x1= College /C1=YES)* P(x2= 44/C1=YES)* P(x3=Female /C1=YES)*P(C1=YES)
= (1/5) * (0.0344) * (2/5) * (5/8)
= 0,00172
No (Age): The age of the people who weren’t accepted for the company:
22
38
20
Mean()= 26.66
Stdev()= 9.86
2
−1 44−26.66
1 ( )
P(x2= 44/C2=NO) = e 2 9.86
= 0.0086
√2 π ( 9.86 ) 2
FINAL DECISION:
Argmax{YES= 0.00172, No= 0.00071667} = YES= 0.00172
The test will belong to the YES class