Struggling with Bayes network

96 Views Asked by At

enter image description here

Im in a machine learning course and bayes networks was presented in such an abstract way I find it really difficult to understand how to use it. And all examples I can find, the final numbers seem appear magically without any explanation. Please help!

I am stuck already at problem 1. I think some of the idea is that $G$ is not going to be a part of the simplified expression because it's not on the path from $B$ to $W$ in the graph (DAG).

I want use Bayes formula:

$$ P(B = tr \ | \ W = tr) = \dfrac{P(B = tr, W = tr)}{P(W = tr)} $$

But I dont know how to continue from there, or expand this expression rather.

I guess if I understand 1, 2 is gonna be easier. Either way Im happy with any help I get. Thanks

1

There are 1 best solutions below

2
On BEST ANSWER

Firstly, I'm going to change notation, so that $W$ is $\{W = tr\}$ and $W^\prime$ is the converse.

We know that the events $B, W$ are conditionally independent given the alarm, so we want to think about the probability of both events for the possible states that the alarm can be in. We can calculate the numerator in your expression as $$P(B, W) = P(B, W, A) + P(B, W, A^\prime).$$ Now we want to convert this into probabilities that we know. The only marginal that we already know is $P(B)$ (and $P(B^\prime)$), so we'll start by conditioning on $B$: $$P(B, W) = P(A, W | B) P(B) + P(A^\prime, W | B) P(B).$$ Due to the structure of the Bayes network we know that $$P(W | A, B) = P(W | A)$$ because Watson's state depends on the state of the alarm, not on what triggered it. Conditioning again, we get $$P(A, W | B) = \frac{P(A, W, B)}{P(B)} = \frac{P(A, W, B)}{P(A, B)} \frac{P(A, B)}{P(B)} = P(W | A, B) P(A | B) = P(W | A) P(A | B)$$ and similarly $$P(A^\prime, W | B) = P(W | A^\prime) P(A^\prime | B).$$ Putting this together, we get $$P(B, W) = P(W | A) P(A | B) P(B) + P(W | A^\prime) P(A^\prime | B) P(B). \\ = 0.9 \cdot 0.99 \cdot 0.01 + 0.5 \cdot (1 - 0.99) \cdot 0.01 \\ = 0.00891 + 0.00005 = 0.00896.$$

To calculate $P(W)$ we would like to be able to use $A$ again and do the following direct calculation: $$P(W) = P(W, A) + P(W, A^\prime) = P(W | A) P(A) + P(W | A^\prime) P(A^\prime)$$ but unfortunately we don't know the marginal probabilities $P(A)$ or $P(A^\prime)$, so we have to calculate them from the marginal probability that we do know, $P(B)$: $$P(A) = P(A, B) + P(A, B^\prime) \\= P(A | B) P(B) + P(A | B^\prime) P(B^\prime) \\ = 0.99 \cdot 0.01 + 0.05 \cdot (1 - 0.01) \\ = 0.0099 + 0.0495 = 0.0594$$ So $P(A) = 0.0594$ and $P(A^\prime) = 1 - P(A) = 0.9406$. We can then calculate $P(W)$ as: $$P(W) = 0.9 \cdot 0.0594 + 0.5 \cdot 0.9406 = 0.52376.$$ Finally, $$P(B | W) = \frac{P(B, W)}{P(W)} = \frac{0.00896}{0.52376} \approx 0.0171.$$