2
9.9kviews
Apply the Naive Bayes classifier algorithm for buys computer classification

and classify the tuple = X(age "young". Income = "medium", student = "yes" and credit - rating = "fair")

ID Age Income Student Credit-rating buys computer
1 young high no fair no
2 young high no good no
3 middle high no fair yes
4 old medium no fair yes
5 old medium no fair yes
6 old low yes good no
7 middle low yes good yes
8 young medium no fair yes
9 young low yes fair yes
10 old medium yes fair yes
11 young medium yes fair yes
12 middle medium no good yes
13 middle high yes fair yes
14 old medium no good no

1 Answer
0
740views

Let c1 buys-comp = "yes"

c2 buys - comp = "xs"

  1. calculate class probabilities

p (1) = 9/4

p (2) = 5/14

  1. calculate p ( c1 | x) = p (x| c1) . p (c1)

p (x | c1) = γ11p(xk|c1)

p (x1|c1) p (age = "young" / c1)

= 2/9

p (x2/c1) = p (income = "med" / c1)

= 4/9

p (x3 / c1) = p (student = "yes" / c1)

= 6/9

p (x4 / c1) = p ( c.r. = "fair" | c1)

0 (x|c1) = 2/9 4/9 6/9 6/9

p (c1/ x) = 2/9 4/9 6/9 6/9 9/14

= 0.0282

  1. Calculate p (c2/x)=p(x|c2),p(c2)

p (x | c2)=γ11p(xk|c2)

k = 1

p (x1/c2) = p ( age = "young" / c2)

= 3/6

p(x2/c2=p(income=""/c2)

= 2/6

p(x3/c2) = p (student = "yes" / c2)

= 1/6

p (x4/c2) = p (c1 = "fair" / c2)

= 2/6

p (x / c2)

= 3/1 2/0 1/6 2/6

p ( c2 / x) = 3/6 2/6 1/6 2/6 6/14

= 0.0036

p (c1 / x) > p (c2/ x)

X E C,

x E bays - comp = "yes"

Please log in to add an answer.