Struggling with Bayes network
up vote
0
down vote
favorite
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
probability statistics machine-learning bayes-theorem bayesian-network
add a comment |
up vote
0
down vote
favorite
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
probability statistics machine-learning bayes-theorem bayesian-network
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
probability statistics machine-learning bayes-theorem bayesian-network
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
probability statistics machine-learning bayes-theorem bayesian-network
probability statistics machine-learning bayes-theorem bayesian-network
edited Nov 24 at 0:55
Bernard
116k637108
116k637108
asked Nov 24 at 0:53
Amoz
1949
1949
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
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.$$
thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
– Amoz
Nov 25 at 15:49
That was a mistake - thanks for spotting it. I've corrected my answer
– Alex
Nov 26 at 13:29
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
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.$$
thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
– Amoz
Nov 25 at 15:49
That was a mistake - thanks for spotting it. I've corrected my answer
– Alex
Nov 26 at 13:29
add a comment |
up vote
1
down vote
accepted
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.$$
thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
– Amoz
Nov 25 at 15:49
That was a mistake - thanks for spotting it. I've corrected my answer
– Alex
Nov 26 at 13:29
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
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.$$
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.$$
edited Nov 26 at 13:27
answered Nov 24 at 16:46
Alex
341212
341212
thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
– Amoz
Nov 25 at 15:49
That was a mistake - thanks for spotting it. I've corrected my answer
– Alex
Nov 26 at 13:29
add a comment |
thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
– Amoz
Nov 25 at 15:49
That was a mistake - thanks for spotting it. I've corrected my answer
– Alex
Nov 26 at 13:29
thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
– Amoz
Nov 25 at 15:49
thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
– Amoz
Nov 25 at 15:49
That was a mistake - thanks for spotting it. I've corrected my answer
– Alex
Nov 26 at 13:29
That was a mistake - thanks for spotting it. I've corrected my answer
– Alex
Nov 26 at 13:29
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3011040%2fstruggling-with-bayes-network%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown