## Tuesday, 20 May 2014

### How To WorkOut Navie Bayes Algorithm

#### Prior Probabilities

``````Prior Probabilities
-------------------

P(yes) = 9/14 = 0.643
Given that the class label is "yes" the universe is 14 = yes(9) + no(5). 9 of them is yes
P(no) = 5/14 = 0.357
Given that the class label is "no" the universe is 14 = yes(9) + no(5). 5 of them is no

``````

#### Probability of Likelihood

``````Probability of Likelihood
-------------------------

P(youth/yes) = 2/9 = 0.222
Given that the class label is "yes" the universe is 9. 2 of them are youth.
P(youth/no) = 3/5 = 0.600
...
...
P(fair/yes) = 6/9 = 0.667
P(fair/no) = 2/5 = 0.400

``````

``` ```

``` ```

#### ``` We need to ```

``` Maximize P(X|Ci )P(Ci ), for i = 1, 2 P(Ci ) - the prior probability of each class, can be computed based on the training tuples: ```

``````
P(yes/youth,medium,yes and fair)
= P(youth/yes)* P(medium/yes)* P(yes/yes)* P(fair/yes) * P(yes)
= (0.222* 0.444* 0.667* 0.667) * 0.643
= 0.028

P(no/youth,income,medium,yes and fair)
= P(youth/no)* P(medium/no)* P(yes/no)* P(fair/no) * P(no)
= (0.600* 0.400* 0.200* 0.400) * 0.357
= 0.007

``````
``` ```