# In Naive Bayes classifier how is P(sneezing,builder|flu) = P(sneezing|flu)P(builder|flu)?

Please refer to this literature:

According to Naive Bayes classification algorithm:

$$P(\text{sneezing},\text{builder}\mid\text{flu}) = P(\text{sneezing}\mid\text{flu})P(\text{builder}\mid\text{flu})$$

where sneezing and builder are independent events.

How do they arrive at the above conclusion mathematically?

Is it something like:

\begin{align} & P(\text{sneezing},\text{builder}\mid\text{flu})\\[6pt] = {} & P(\text{sneezing} \cap \text{builder} \mid \text{flu}) \\[6pt] = {} & \frac{P((\text{sneezing} \cap \text{builder}) \cap \text{flu})}{P(\text{flu})} \end{align}

• Maybe writing in this way $P[sneezing,builder|flu] = P[(sneezing|flu),(builder|flu)] = P[(sneezing|flu)\cap (builder|flu)] = P(sneezing|flu)P(builder|flu)$ for easy understanding. – user158565 Jul 8 '19 at 16:28
• @user158565 What is the mathematics behind it? – Soumee Jul 8 '19 at 16:30
• The first =: I think the condition $|flu$ in $P[sneezing,builder|flu]$ should mean that sneezing is also conditional on flu. The sencond =: Just replace , by $\cup$. "Both A and B happen" can be written as (A,B) or $(A\cap B)$, but $(A\cap B)$ in formal writing. The third =: Given (sneezinf|flu) and (buider|flu) are independent, the probability of both of them happening is the product of their probability. – user158565 Jul 8 '19 at 16:42

## 2 Answers

Your link states So assuming that sneezing has no impact on whether you're a builder, we can say that $$P(sneezing,builder|flu) = P(sneezing|flu)P(builder|flu)$$.

This statement should be stated more clearly either as

1) The events "sneezing" and "builder" are independent.

OR

2)The events "sneezing" and "builder" are conditionally independent on the event "flu".

In the first case (independence) the joint probability is equal to the product of the marginal probabilities, and this is also true for the conditional probabilities if everything is conditioned on the same event ("flu" in this case).

In the second case (conditional independence), the joint conditional probability is equal to the product of the marginal conditional probabilities (but it doesn't follow automatically that "sneezing" and "builder" are independent generally like in the first case).

Let $$S$$ denote "$$\text{sneezing}$$", $$B$$ denote "$$\text{builder}$$" and $$F$$ denote "$$\text{flu}$$" for notational simplicity. In order for the following to be true, you need conditional independence (conditioned on $$F$$) of $$B$$ and $$S$$: $$P(B,S|F)=P(B|F)P(S|F)$$ And, this relation doesn't imply anything about the independence of $$B$$ and $$S$$; we can only say that these events are conditionally independent, nothing more. So, $$B$$ and $$S$$ can be dependent events.

Since, there is an underlying assumption of conditional independence, you can't just reach this statement via Bayes Rule or joint/conditional probability formula. The critical keyword here is Naive. Naive Bayes algorithm assumes that features are conditionally independent given the class. Here, $$F$$ is your class, and $$B,S$$ are your features. Typical "Bayes Classifier" wouldn't make this assumption, and you'd model the dependency between these features somehow, but this isn't the case with "Naive Bayes" algorithm.