Download presentation
Presentation is loading. Please wait.
1
Propagation Algorithm in Bayesian Networks
Saturday, August 20, 2016 Farrokh Alemi, PhD. This lecture shows how to predict an event given a Bayesian network and its specifications. The lecture describes Bayes belief network propagation and based in part on the information in and in
2
Definition: Partial Table
p(S,T) S T p Severe Treated 0.4 Not Treated 0.1 Not Severe 0.2 Not severe 0.3 Total 1 p(s,T) S T p Not Severe Treated 0.2 Not severe Not Treated 0.3 Total 0.5 Recall that partial table refers to portion of a table with fixed levels of a variable. On the left we see a table for the combination of severity and treatment. Note that capital letters in our formula refers to all levels of the variables so with capital S we refer to both severe and not severe levels. The table on the left provides the frequency with which the treatment occurs in patients with different combination of severity and treatment. The first row says that 40% of patients we see are severely ill and treated. The last row says that 30% are not severely ill and not treated. On the right we see the partial table for patients who are not severely ill. Note that in a partial tables the probabilities do not add to 1.
3
Definition: Conditional Table
p(s,T) S T p Not Severe Treated 0.2 Not severe Not Treated 0.3 Total 0.5 p(T|s) S T p Not Severe Treated 0.4 Not severe Not Treated 0.6 Total 1 A single conditional refers to the probability of a variable given fixed levels of another. In here we see that probability of treatment among patients who were not severely ill. Note that in a conditional table the probabilities add up to 1.
4
Definition: Two Separate Conditionals
p(s|T) s T p Not Severe Treated 0.2 Not severe Not Treated 0.3 One can also estimate the conditional probability of having a particular value of another variable. There is of course no reason for this to add up to one.
5
Cycles of Joining & Eliminating
Join tables with unwanted variable Eliminate unwanted variables Stop if no unwanted variables The effect of changes in a network can be calculated by repeatedly going through two steps known as joining and eliminating.
6
Cycles of Joining & Eliminating
R ? Cycles of Joining & Eliminating p(S) S p Severe 0.1 Not Severe 0.9 Total 1 p(R|S) S R p Severe DNR 0.8 No DNR 0.2 Not Severe 0.1 Not severe 0.9 Let us start with a simple tree with 3 variables: patients severity, patients preferences for DNR and treatment choice. Our task is to estimate the probability of treatment. To start with we have two tables. One providing the prior probability of severity and the other conditional probability of DNR order at different levels of severity. We will try to first join these two tables.
7
Joining S T R ? 0.1 x 0.8 0.1 x 0.2 0.9 x 0.1 0.9 x 0.9 p(S) S p
Severe 0.1 Not Severe 0.9 p(R|S) S R p Severe DNR 0.8 No DNR 0.2 Not Severe 0.1 Not severe 0.9 p(R,S) S R p Severe DNR 0.08 No DNR 0.02 Not Severe 0.09 Not severe 0.81 0.1 x 0.8 0.1 x 0.2 The joining works like joining of tables in SQL. The tables are joined on variables they share, in this case the severity of the illness. The values of the new joint table are provided by multiplying each conditional probability by the prior probability of the condition. For example, the first row of the new joint table is provided by multiplying the probability of being severe, .1 from the first table to the conditional probability of DNR for severe patients, .8 from the second table. The resulting new table can be used to join with another. But before we join to another table, we need to eliminate the variables that we are not interested in. 0.9 x 0.1 0.9 x 0.9
8
Elimination (Sum Over Undesirables)
? Elimination (Sum Over Undesirables) p(R,S) S R p Severe DNR 0.08 No DNR 0.02 Not Severe 0.09 Not severe 0.81 p(R) R p DNR 0.17 No DNR 0.83 p(R,S) Sorted S R p Severe DNR 0.08 Not Severe 0.09 No DNR 0.02 Not severe 0.81 Elimination is done by summing over the variable that we are not interested in. Since we want to estimate the probability of treatment, we are not interested in the patient’s severity. We can eliminate this variable by summing across it. To show the summation easier we sorted over the variable we want to keep. The we sum the values for DNR and no DNR. This new table no longer indicates severity of illness but reflects the influence of severity.
9
Join Again S T R ? p(R) R p DNR 0.17 No DNR 0.83 p(T|R) T R p Treated
0.08 No DNR 0.61 Not Treated 0.20 0.11 p(T,R) T R p Treated DNR 0.014 No DNR 0.506 Not Treated 0.034 0.091 For our next step we join our new table with the conditional probability of treatment given DNR. We are joining the two tables on the shared variables across the two tables. In this case the two tables share the DNR choice. As before, the shared feature across the two tables is used to multiply the related probabilities.
10
Eliminate Again S T R ? p(T,R) T R p Treated DNR 0.014 No DNR 0.506
Not Treated 0.034 0.091 p(T) T p Treated 0.52 Not Treated 0.125 Total 0.645 p(T) T p p normalized Treated 0.52 0.81 Not Treated 0.13 0.19 Total 0.65 1 Since we are interested in the probability of treatment, then we can eliminate DNR variable by summing across it. Since these calculated estimates do not always add up to 1, we normalize the estimates so that they do. So in the final estimate we have that 81% of the patients receive the treatment. We have been able to go through the tree and estimate the probability of treatment.
11
Algorithm with Substantiated Variables
Join tables with unwanted variable Eliminate unwanted variables Stop if no unwanted variables Remove unsubstantiated rows If a variable is substantiated, meaning that it has occurred, then we remove all rows corresponding to unsubstantiated levels of the variable. Then we first join all substantiated variables. Then join a table with a variable not needed at end of the calculation. This is done through multiplication of probabilities of joined tables. Next eliminate the unneeded variable. This is done through summation. If all unneeded variables are eliminated then normalize and use the estimated probabilities. Let us look at an example.
12
Remove Unsubstantiated Levels
p(severity) p(DNR) p(Tx|DNR, Severity) p(Outcome|Tx, Severity) Severity p DNR Tx Outcome Severe 0.4 Yes 0.1 Positive 0.2 Not Severe 0.6 No Negative 0.0 0.3 Let us assume that we want to predict the outcome for severe patients. Therefore, rows that correspond to not severely ill patients should be removed from all tables. These are the four local tables in our network.
13
Remove Unsubstantiated Levels
p(severity) p(DNR) p(Tx|DNR, Severity) p(Outcome|Tx, Severity) Severity p DNR Tx Outcome Severe 0.4 Yes 0.1 Positive 0.2 Not Severe 0.6 No Negative 0.0 0.3 Since we are focused on severe patients, the rows from three tables about “not severely ill” patients are removed. Typically, this is done by a where SQL command at the point of joining tables.
14
Join Severity and DNR S R T O
SELECT [p(Sev)].Severity, [p(DNR)].DNR, [p(DNR)]![p]*[p(Sev)]![p] AS p FROM [p(DNR)], [p(Sev)] WHERE ((([p(Sev)].Severity)="Severe")); This code says that we should join the two tables. Since they have no shared features, the join is cross join. After the join the probability of combination events are calculated as a product of the probabilities. It also says that the join should be limited to severe cases. The resulting join is shown here. The probability of severe illness and DNR is estimated as 0.16, which is the product of 0.4 in the other two tables. p(severity) p(DNR) Severity p DNR Severe 0.4 Yes Not Severe 0.6 No p(Sev DNR) Severity DNR p Severe Yes 0.16 No 0.24
15
No Elimination S R T O p(Sev DNR) Severity DNR p Severe Yes 0.16 No
0.24 We cannot eliminate neither DNR or Severity from this table as these variables are also used in remaining network structure. Severity is used in both treatment and outcome tables and DNR is used in the treatment variable
16
Join Again S R T O p(Sev DNR) Severity DNR p Severe Yes 0.16 No 0.24
p(Tx|DNR, Severity) DNR Severity Tx p Yes Severe 0.1 No 0.2 Not Severe 0.0 0.3 p(Sev DNR) Severity DNR p Severe Yes 0.16 No 0.24 In our next step we want to join the combined table of Severity and DNR with table for treatment.
17
Join Again S R T O SELECT [p(Tx|DNR Sev)].Tx,
[p(Tx|DNR Sev)].Severity, [p(Tx|DNR Sev)].DNR, +[p(Tx|DNR Sev)]![p]*[p(Sev DNR)]![p] AS p FROM [p(Sev DNR)] INNER JOIN [p(Tx|DNR Sev)] ON ([p(Sev DNR)].Severity = [p(Tx|DNR Sev)].Severity) AND ([p(Sev DNR)].DNR = [p(Tx|DNR Sev)].DNR); The SQL for this join is given as shown. Note that the two tables now share two features; severity and DNR orders.
18
Join Again with Treatment
S T R Join Again with Treatment p(Sev DNR) p(Tx|DNR, Severity) Severity DNR p Tx Severe Yes 0.16 0.1 No 0.072 0.24 0.2 0.024 0.3 0.016 0.032 The resulting Table is provided here. Note that only the severe cases are carried through the join as the earlier tables do not have cases of not severely ill patients. Note that that probability in the resulting tables do not add up to one. This is ok, these estimates do not have to add up to one. We can now remove the DNR variable as it is no longer in use in any remaining tables.
19
O S T R Eliminate DNR SELECT [p(Tx Sev DNR)].Tx, [p(Tx Sev DNR)].Severity, Sum([p(Tx Sev DNR)].p) AS psum FROM [p(Tx Sev DNR)] GROUP BY [p(Tx Sev DNR)].Tx, [p(Tx Sev DNR)].Severity; We can eliminate DNR by grouping by the other variables in the table and summing across DNR. The code and the result are shown here. In our final join we would join with the table on outcomes. p(Tx Sev) Tx Severity psum No Severe 0.06 Yes 0.09
20
p(Outcome|Tx, Severity)
Join with Outcomes p(Tx Sev) p(Outcome|Tx, Severity) Tx Severity psum Outcome p No Severe 0.06 Yes Positive 0.2 0.09 Negative 0.1 0.3 The two tables that we need to join are shown here. Note how the non severe cases are no longer part of each table.
21
p(Outcome|Tx, Severity)
Join with Outcomes p(Tx Sev) p(Outcome|Tx, Severity) p(Tx Sev Outcome) Tx Severity psum Outcome p No Severe 0.06 Yes Positive 0.2 0.018 0.09 Negative 0.1 0.009 0.006 0.3 0.017 Note again that in the new table of treatment, severity and outcome, the calculated probabilities do not add up to one These numbers are proportional to probability and normalizing them to add up to one results in the calculated probabilities. Next we try to eliminate all variables that are not needed and calculate the probability of positive outcome.
22
Eliminate Treatment S R T O SELECT [p(tx sev outcome)].Severity,
[p(tx sev outcome)].Outcome, Sum([p(tx sev outcome)]![p]/[SumOfp]) AS p FROM [p(tx sev outcome)], SumOfP GROUP BY [p(tx sev outcome)].Severity, [p(tx sev outcome)].Outcome; Here again we sum across the groups we want and leave the variables we are not interested out of the group by statement Severity Outcome p Severe Negative 0.52 Positive 0.48
23
Cycles of Join and Elimination Leads to Desired Probabilities
Take Home Lesson Cycles of Join and Elimination Leads to Desired Probabilities Here again we sum across the groups we want and leave the variables we are not interested out of the group by statement
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.