NEWS 

Building a Bayesian Network - Continued

Compiling the BN
Now is the time to compile the net and see how it works:

tool_compile

Figure 7: The run mode tool button

 


The compiler checks for the following errors:

  • Cycles. There must be no cycles in a network (whether or not there is a cycle does not depend on the directions of the arrows)
  • For each parentconfiguration of a node the propabilities of the different states must have the sum of 1. In other words, each column of the table must sum to 1. If there is a column that does not sum to 1, the compiler will normalize the values. This fact can be utilised when filling in the node properties. Say, for example, that the propability of a tree being sick is based on the observation of 13527 trees over one season, where 1678 got sick and the rest didn't. Instead of first calculating the fractions, you just put 1678 in the sick state of the Sick node, and 11849 in the no state. Then the compiler will calculate the proper values of probability

If you have followed the guidance of this tutorial, there should not be any errors in the compilation process. The compilation should be finished very fast with a small BN like ours. After the compilation, the "run" mode is entered (you have so far only been working in "edit" mode).




Running the BN
Running in "run" mode, the network window is split into two by a vertical separation (see figure 8). To the left is the node list pane and to the right is the network pane.

show_test
Figure 8: The network window in "run" mode. To the left is the node list pane (having
Loses and Sick expanded) and to the right is the network pane.  


You can view the probabilities of a node being in a certain state by expanding the node in the node list pane. You expand a node by double clicking it in the node list pane (if you click on the small node icon in the node list pane, you only need to click it once). Now, expand Loses and Sick:

  • Double click Loses in the node list pane
  • Double click Sick in the node list pane

You can also expand all nodes at once by pressing the expand node list tool in the tool bar just to the right of the node properties tool.

Is the tree sick?
Now, imagine that you want to use your BN to find the probability of an apple tree being sick given the information that the tree is losing its leaves. This is done as follows:

  • Expand all nodes (by pressing the expand node list tool)
  • Enter the fact that the tree is losing its leaves by double clicking the state "yes" of the Loses node
  • Propagate the Bbn by pressing the sum propagation tool in the tool bar (see figure 9)
  • Read the probability of Sick being in state "sick"
tool_sum_prop
Figure 9: The sum
propagation tool 


This should give the output shown in figure 10.

show_prop
Figure 10: Our BN after entrance of the evidence that the tree is losing its
leaves and sum propagation 


The probability of the tree being sick is now 0.49.

If you do not read the value specified above, you have probably mistyped something when filling in the CPTs. Then, check the CPTs of all the nodes.

The Monitor Windows
In the last section, you used the node list pane to enter evidence and retrieve beliefs. You can also do this by using the monitor windows. The monitor windows show the same information as the node list pane but you have the opportunity to place the monitor windows near the corresponding nodes of the BN in the network pane. You can open a monitor window for each node in the network pane, but the best way to use them is probably only to open a monitor window for the nodes in the BN which have special interest. Else, they might take up too much space.

Now, we shall open monitor windows for Sick and Loses and repeat the calculations from before. First, initialize the BN:

  • Press the initialize tool button (to the left of the sum propagation tool)

Then, we are ready to open the monitor windows of Sick and loses.

  • Select Sick and Loses (hold down the SHIFT key to select more nodes at the same time)
  • Choose "Show Monitor Windows" from the "View" menu
show_monitors
Figure 11: Monitor windows of Sick and loses are now shown in the network pane 


Now you know all you need to know to continue to the second tutorial showing you how to construct a Hugin knowledge base using influence diagrams. The rest of this first tutorial introduces some very useful aspects of the Hugin GUI but can be skipped.

The most Likely Combination
From the propagation in the previous section we could see that the probability of the tree suffering from drought is 0.47. In both the case of Sick and Dry it is more likely that the state is "not". This could make one believe that the most likely combination of states is when both Sick and Dry are in state "not". However, this is a wrong conclusion. If you want to find the most likely combination of states in all nodes, you should use max propagation (in stead of sum propagation). The max propagation tool is found in the tool bar just to the right of the sum propagation tool.

Now, try to press the max propagation tool. In each node, a state having the value 100.00 belongs to a most likely combination of states. In this case, this gives one unique combination being the most likely: Sick is "sick" and Dry is "not"

We see that even if Sick="sick" is less likely than Sick="not", Sick="sick" is contained in the most likely combination of the states of the nodes while Sick="not" is not. This shows that you need to be careful about your conclusions from the result of a propagation.

Now, one might want to know the probability of this most likely combination of states (or of any other combination of states) under the assumption that the entered evidence holds.

Calculating the Probability of a Combination of States
Here, we shall describe a technique to calculate the probability of the most likely combination of states given the evidence that the apple tree is losing its leaves. This probability is written:

P(Sick="yes", Dry="not" | Loses="yes")

Any time you perform sum propagation in your BN, the probability of the entered evidence is shown in the lower left corner of the HUGIN Runtime window (the P(All) value). If you have chosen the "yes" state of the Loses node and performed sum propagation, you can read the probability of Loses="yes" (written P(Loses="yes")). This value should be 0.1832.

The technique uses the following rule from probability theory (known as the fundamental rule):

P(A, B) = P(A | B) P(B)

The only kind of probability we can get from HUGIN is the probability of a series of bits of evidence which can be written in the form:

P(A1, A2,..., An)

We use the fundamental rule to rewrite our requested probability to some expression composed by such components:

P(Sick="yes", Dry="not" | Loses="yes")
= P(Sick="sick", Dry="not", Loses="yes") / P(Loses="yes")

In the fundamental rule, we have divided both sides with P(B). Then we have substituted A with Sick="yes", Dry="not" and B with Loses="yes".

We already know P(Loses="yes") so we only need to calculate P(Sick="sick", Dry="not", Loses="yes"). This is done as follows:

  • Enter Sick="sick", Dry="not", and Loses="yes" in the BN
  • Press the sum propagation tool
  • Read P(Sick="sick", Dry="not", Loses="yes") as the P(All) value in the lower left corner

This value should be 0.081. Now, we are ready to calculate the requested probability:

P(Sick="yes", Dry="not" | Loses="yes")
= 0.081 / 0.1832
= 0.442

So, the probability of the most likely combination of states of Sick and Dry, given that Loses="yes", is 0.442.

This finishes the first tutorial. If you want to learn how to construct a small influence diagram, you should go through the second tutorial .

Hugin Expert A/S · Gasværksvej 5 · DK·9000 Aalborg · Denmark · Phone +45 9655 0790 · Fax +45 9655 0799 · info@hugin.com
© Copyright 2004 · All rights reserved · Copyright Policy