# Making naïve Bayes less naïve by accounting for mutual dependence

I'm playing with the pet example of figuring out the probability someone has the flu given certain symptoms, namely fever and nausea.

Let's define our priors, considering the "probability of x" as the probability one has "x" on any given day:

$$p(\textrm{Flu})=0.38\%$$ $$p(\textrm{Fever}|\textrm{Flu})=95\%$$ $$p(\textrm{Fever}|\widetilde{\textrm{Flu}})=5\%$$ $$p(\textrm{Nausea}|\textrm{Flu})=90\%$$ $$p(\textrm{Nausea}|\widetilde{\textrm{Flu}})=1\%$$

We begin with a probability of $$0.38\%$$ that Sarah has the flu today.

We measure her temperature, and she has a fever, so we update our prior.

$$p(\textrm{Flu}|\textrm{Fever})=\frac{p(\textrm{Flu})*p(\textrm{Fever}|\textrm{Flu})}{p(\textrm{Flu})*p(\textrm{Fever}|\textrm{Flu})+p(\widetilde{\textrm{Flu}})*p(\textrm{Fever}|\widetilde{\textrm{Flu}})}$$

$$p(\textrm{Flu}|\textrm{Fever})=\frac{0.38\%*95\%}{0.38\%*95\%+99.62\%*5\%}=6.76\%$$

P.S. I'd really like to know how we incorporate her current temperature, and the distribution of temperatures of people who have the flu vs. people who don't, turning Sarah's fever from a binary question (does she have a fever) into a continuous one (what is her temperature). How do we do this, if we have her recorded temperature distributions for each of the flu and non-flu conditions?

Now she mentions nausea, so we update our first posterior, or second prior.

$$p(\textrm{Flu}|\textrm{Fever}\cap\textrm{Nausea})=\frac{p(\textrm{Flu})*p(\textrm{Fever}|\textrm{Flu})*p(\textrm{Nausea}|\textrm{Flu})}{p(\textrm{Flu})*p(\textrm{Fever}|\textrm{Flu})*p(\textrm{Nausea}|\textrm{Flu})+p(\widetilde{\textrm{Flu}})*p(\textrm{Fever}|\widetilde{\textrm{Flu}})*p(\textrm{Nausea}|\widetilde{\textrm{Flu}})}$$

$$p(\textrm{Flu}|\textrm{Fever}\cap\textrm{Nausea})=\frac{0.38\%*95\%*90\%}{0.38\%*95\%*90\%+99.62\%*5\%*1\%}=86.7\%$$

This would be all well and good if fever and nausea were independent, but clearly they're not. In fact, while we've implicitly made the following assumptions,

$$p(\textrm{Fever}|\textrm{Nausea})=p(\textrm{Fever})=p(\textrm{Fever}|\textrm{Flu})*p(\textrm{Flu})+p(\textrm{Fever}|\widetilde{\textrm{Flu}})*p(\widetilde{\textrm{Flu}})=5.34\%$$

$$p(\textrm{Nausea}|\textrm{Fever})=p(\textrm{Nausea})=p(\textrm{Nausea}|\textrm{Flu})*p(\textrm{Flu})+p(\textrm{Nausea}|\widetilde{\textrm{Flu}})*p(\widetilde{\textrm{Flu}})=1.34\%$$

I'd actually say that the following would be more accurate,

$$p(\textrm{Fever}|\textrm{Nausea})=20\%$$

$$p(\textrm{Nausea}|\textrm{Fever})=10\%$$

So our assumption of independence is very far from accurate, and $$p(\textrm{Flu}|\textrm{Fever}\cap\textrm{Nausea})$$ should account for this. How do we update $$p(\textrm{Flu}|\textrm{Fever}\cap\textrm{Nausea})$$ to take into account dependence between fever and nausea?

\begin{align}\mathbb P(\text {Fever}|\text{Nausea})&=\mathbb P(\text{Fever}|\text{Nausea},\text{Flu})\mathbb P(\text{Flu}|\text{Nausea})+\mathbb P(\text{Fever}|\text{Nausea},\text{Flu}')\mathbb P(\text{Flu}'|\text{Nausea})\\&=\mathbb P(\text{Fever}|\text{Flu})\mathbb P(\text{Flu}|\text{Nausea})+\mathbb P(\text{Fever}|\text{Flu}')\mathbb P(\text{Flu}'|\text{Nausea})\\&=0.95\times 0.255+0.05\times0.745\\&\approx 0.28\end{align}
A simple model can use an integer RV called $$T$$, for example with a discrete distribution, e.g. $$P(T=t|\text{Flu})$$. So, given the temperature of Sarah, you'll again substitute the probabilities as usual.