# Graphical Probabilistic Representation of Naive Bayes

Given the Naive Bayes graphical representation below, I want to calculate $P(X|Y_1,Y_2)$.

Are the calculations below correct? The factored joint distribution regarding the system is: $$P(X,Y_1,Y_2)=P(X) \cdot P(Y_1|X) \cdot P(Y_2|X)$$ $$\frac{P(X,Y_1,Y_2)}{P(X)}=P(Y_1|X) \cdot P(Y_2|X)$$ $$P(Y_1,Y_2|X)= P(Y_1|X) \cdot P(Y_2|X)$$ Using Bayes rule to flip the left hand side: $$\frac{P(X|Y_1,Y_2) \cdot P(Y_1,Y_2)}{P(X)}= P(Y_1|X) \cdot P(Y_2|X)$$ $$P(X|Y_1,Y_2) = \frac{P(Y_1|X) \cdot P(Y_2|X) \cdot P(X)}{P(Y_1,Y_2)}$$ $$P(X|Y_1,Y_2) = \frac{P(Y_1|X) \cdot P(Y_2|X) \cdot P(X)}{P(Y_1) \cdot P(Y_2)}$$

Up to the last line, like Henry already pointed out, is all correct. What you could write is,

$$P(X|Y_{1},Y_{2}) = \frac{P(Y_{1},Y_{2}|X)P(X)}{\sum_{X}P(Y_{1},Y_{2}|X)P(X)} = \frac{P(Y_{1},|X)P(Y_{2},|X)P(X)}{\sum_{X}P(Y_{1},|X)P(Y_{2},|X)P(X)}$$

$Y_{1}$ and $Y_{2}$ are only independent given $X$.

No, the move from your penultimate equation to the final equation has an error.

In general you should not say $P(Y_1,Y_2)= P(Y_1)P(Y_2)$.

According to the Naive Bayesian graph, the covariate $Y_1$ is independent of the covariate $Y_2$.

Therefore $P(Y_1|X) \cdot P(Y_2|X)=P(Y_1,Y_2|X)$ and $P(Y_1,Y_2) = P(Y_1) \cdot P(Y_2)$

Implementing these into your last equation, you can see that:

$$P(X|Y_1,Y_2) = \frac{P(Y_1,Y_2|X) \cdot P(X)}{P(Y_1,Y_2)}$$

• Don't know much about Naive Bayes. However, looking at the graph, Y1 and Y2 are only conditionally independent given X. Think of them as points uniformly distributed on a frisbee, and X as the co-ordinates of where the frisbee lands – conjectures Nov 8 '13 at 14:57