# How do I quickly calculate a Bayes classifier?

With the data from this post I want to quickly answer the following exam question:

Given that it is rainy, not windy, the temperature is hot and humidity is normal, should you play golf or not? Show all workings of solutions to arrive at your final answers. (calculate the exact, not proportional, probability values to make your decision and round them to 3 decimal places to make comparisons)

$$posterior = \frac {prior \cdot likelihood} {evidence}$$

I constructed the following as a summary of the data

I found the table helpful in preventing counting mistakes ( since the totals need to agree )
So applying the formula:

$$post(G) = \frac {prior(G) \cdot likelihood(G|R,H,N,!W)} {evidence}$$ $$post(!G) = \frac {prior(!G) \cdot likelihood(!G|R,H,N,!W) } {evidence}$$ And calculating: $$prior(G) = \frac{9}{14}$$ $$prior(!G)=\frac{5}{14}$$ $$likelihood(G|R,H,N,!W) = \frac{2}{9} \cdot \frac{2}{9} \cdot \frac{6}{9} \cdot \frac{6}{9} = \frac{16}{729}$$ $$likelihood(!G|R,H,N,!W) = \frac{3}{5} \cdot \frac{2}{5} \cdot \frac{1}{5} \cdot \frac{2}{5} = \frac{12}{625}$$ I get: $$numerator(G)=\frac{9}{14} \cdot \frac{16}{729} \approx 0.0141$$ $$numerator(!G)=\frac{5}{14} \cdot \frac{12}{625} \approx 0.00686$$ $$evidence = numerator(G)+numerator(!G) = 0.021$$ so $$post(G) = \frac{.0141}{.021} =0.674$$ and $$post(!G) = \frac{.00686}{.021} =0.327$$

• Have I constructed the Naive Bayes Classifier?
• If so, what part of these equations is the actual "classifier"?
• Do I need to calculate the evidence to properly answer the question?
• Could I just say the odds are 141 to 69 that I should play golf?

Yes, you have. Because, your likelihood calculation was $$P(R,H,N,W'|G)=P(R|G)P(H|G)P(N|G)P(W'|G)$$
The classifier compares $$P(G|R,H,N,W')$$ vs $$P(G'|R,H,N,W')$$ and picks the larger one. This comparison is the classification action. In Bayes/Naive Bayes, we typically don't calculate the denominator since it is the same for both, which answers your third question.