2
9.3kviews
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
714views

Let $c_1$ $\rightarrow$ buys-comp = "yes"

$c_2$ $\rightarrow$ buys - comp = "xs"

  1. calculate class probabilities

p (1) = 9/4

p (2) = 5/14

  1. calculate p ( $c_1$ | x) = p (x| $c_1$) . p ($c_1$)

p (x | $c_1$) = $\frac{\gamma}{11} p (xk | c_1)$

$\therefore$ p ($x_1 | c_1)$ p (age = "young" / $c_1$)

= 2/9

p ($x_2/ c_1)$ = p (income = "med" / $c_1$)

= 4/9

p (x3 / $c_1$) = p (student = "yes" / $c_1$)

= 6/9

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

$\therefore$ 0 (x|$c_1$) = 2/9 4/9 6/9 6/9

$\therefore$ p ($c_1$/ x) = 2/9 4/9 6/9 6/9 9/14

= 0.0282

  1. Calculate p ($c_2 /x) = p( x| c_2) , p (c_2)$

p (x | $c_2) = \frac{\gamma}{11} p (x_k | c_2)$

k = 1

$\therefore$ p ($x_1 / c_2)$ = p ( age = "young" / $c_2$)

= 3/6

$p (x_2 / c_2 = p (income = " " / c_2 $)

= 2/6

$p ( x_3 / c_2)$ = p (student = "yes" / $c_2)$

= 1/6

p ($x_4 / c_2 $) = p $(c_1$ = "fair" / $c_2$)

= 2/6

$\therefore$ p (x / $c_2$)

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

$\therefore$ p ( $c_2$ / x) = 3/6 2/6 1/6 2/6 6/14

= 0.0036

$\because$ p ($c_1$ / x) > p ($c_2$/ x)

X E C,

$\therefore$ x E bays - comp = "yes"

Please log in to add an answer.