First Step
Find Classes:
C1: buys_computer = ‘yes’
C2: buys_computer = ‘no’
Second Step
Find P(C1) and P(C2)
P( buys_computer = “yes”) = 9/14 = 0.643
P( buys_computer = “no”) = 5/14= 0.357
Third Step
Compute P (X|C) for each class :
P (age = “Youth” / buys_computer = “yes”) = 2/9 = 0.222
P (age = “Youth” / buys_computer = “no”) = 3/5 = 0.6
P (income = “medium” / buys_computer = “yes”) = 4/9 = 0.444
P (income = “medium” / buys_computer = “no”) = 2/5 = 0.4
P (student = “yes” / buys_computer = “yes) = 6/9 = 0.667
P (student = “yes” / buys_computer = “no”) = 1/5 = 0.2
P (credit_rating = “fair” / buys_computer = “yes”) = 6/9 = 0.667
P (credit_rating = “fair” / buys_computer = “no”) = 2/5 = 0.4
Fourth Step .
Find P(X|Ci) :
For C1: Multiply all the probabilities that belong to class “yes”
P(X|buys_computer = “yes”) = 0.222 x 0.444 x 0.667 x 0.667=.044
Similarly for “class = no”
P(X|buys_computer = “no”) = 0.6 x 0.4 x 0.2 x 0.4 = 0.019
Finally ,
find …… P(X|Ci)*P(Ci) ……. for each class
P(X|buys_computer = “yes”) * P(buys_computer = “yes”) = 0.028
P(X|buys_computer = “no”) * P(buys_computer = “no”) = 0.007
参考:
http://www.cnblogs.com/phinecos/archive/2008/10/21/1315948.html
http://summerbell.javaeye.com/blog/392459
http://blog.csdn.net/DL88250/archive/2008/02/20/2108164.aspx
http://www.cnblogs.com/waemz/archive/2009/02/25/1397647.html