Naive Bayes Classifier Method
Here, we want to classify a Homeowner = Yes, Status = Employed, Income = Average and predict the class label for this sample.
- The above sample dataset does not contain the class label for this sample.
- Hence, by using Naïve Bayes Classifier we can find out the class table value for the given sample.
- To do this we need to calculate the below probabilities:
First, calculates the Probabilities for $P(x | Yes)$
$$P(Yes) = \frac{3}{10} $$
$$ P(Homeowner = Yes│Yes) = \frac{0}{3} = 0 $$
$$ P(Status = Employed│Yes) = \frac{1}{3} $$
$$ P(Income = Average│Yes) = \frac{3}{3} = 1 $$
Second, calculates the Probabilities for $P(x | No)$
$$P(No) = \frac{7}{10}$$
$$P(Homeowner = Yes│No) = \frac{3}{7}$$
$$P(Status = Employed│No) = \frac{3}{7}$$
$$P(Income = Average │No) = \frac{1}{7}$$
According to Naïve Bayes Classifier
$$P(C│X)=P(x1│C) × P(x2│C) ×…………P(xn│C) × P(C)$$
Therefore, Probability for Class label value Yes we have
$$Yes = P(X│Yes) × P(Yes)$$
$$Yes = P(Homeowner = Yes│Yes) × P(Status = Employed│Yes) × P(Income = Average│Yes) × P(Yes)$$
$$= 0 ×\frac{1}{3} × 1 × \frac{3}{10} = 0$$
If one of the conditional probabilities is zero, then the entire expression becomes zero. This can be seen in the above scenario.
Therefore, Probability for Class label No we have
$$ No =P(X│No) × P(No)$$
$$No = P(Homeowner = Yes│No) × P(Status = Employed│No) × P(Income = Average │No) × P(No)$$
$$= \frac{3}{7} × \frac{3}{7} × \frac{1}{7} × \frac{7}{10} = 0.018$$
As
$$P(X│No).P(No) \gt P(X│Yes).P(Yes)$$
$$because,\ 0.018 \gt 0$$
Therefore, this sample (Homeowner = Yes, Status = Employed, Income = Average) gets classified under Class label ’No’.