We will demonstrate how GeNIe can be used to build a Bayesian network on a simple example. While this example contains only two variables, it illustrates all basic concepts, which once understood can be used in building much more complex real models.
Consider the following scenario:
Imagine a venture capitalist who considers a risky investment in a startup company. A major source of uncertainty about her investment is the success of the company. She is aware of the fact that only around 20% of all startup companies succeed. She can reduce this uncertainty somewhat by asking expert opinion. Her expert, however, is not perfect in his forecasts. Of all startup companies that eventually succeed, he judges about 40% to be good prospects, 40% to be moderate prospects, and 20% to be poor prospects. Of all startup companies that eventually fail, he judges about 10% to be good prospects, 30% to be moderate prospects, and 60% to be poor prospects.
How can our investor use the information from the expert? What is the chance for success if the expert judges the prospects for success to be good? What if he judges them to be poor?
We will create a Bayesian network that will allow us to determine the exact numerical implications of the expert's opinion on the investor's expectation of success of the venture. The Bayesian network will contain two nodes representing random variables: Success of the venture and Expert forecast.
If you have not already started GeNIe, start it now. If you need help in starting GeNIe, Use the Starting GeNIe tutorial.
The Tool Menu shows a list of different types of nodes that you can create. These are also displayed as buttons on the Standard Toolbar.
A. Let us create the node for the variable Success of the venture.
Select [Chance] button from the Standard Toolbar or Tool Menu
The Chance button will become recessed and the cursor will change to an arrow with an ellipse in bottom right corner []. Move the mouse to a clear portion of the screen inside GeNIe window and click the left mouse button. You will see a new node appear on the screen as shown below:
The small squares around the node indicate that the node is selected. The most recently created node is automatically selected. You can also select any node by single-clicking on it. You can change the size of the selected node by dragging the small squares.
If you want to draw multiple nodes of the same type, then you can avoid having to select the node button again and again by double-clicking on a node button instead of single-clicking it the first time. This will place you in "sticky mode," in which the tool button stays recessed and you can draw multiple nodes of that type. You can return to normal mode by clicking on the Select button or clicking on the recessed button again.
Once the node has been drawn on the Graph View the Chance button on the toolbar will become normal again and the Select button will become recessed.
The label for the created node is Node1. This name is automatically assigned by GeNIe. GeNIe also places the node name in Edit mode immediately, so you can enter a more descriptive name if you want.
GeNIe associates two labels with each node: an identifier and a name. Identifiers are similar to variable names in programming languages: they should start with a letter followed by any sequence of letters, digits or underscore characters. Names are simply strings of characters with no limitations. GeNIe assigned the node that you have just created identifier and name Node1.
B. Let us assign a meaningful identifier and name for the newly created node.
Double click on the node Node1.
GeNIe will display the following dialog box:
This is the Node Property Sheet. The Node Property Sheet is used to specify various properties of the node.
Now change the identifier to Success and the name to Success of the venture.
C. Now we will define the outcomes of this variable( node ) and their probabilities. We can do this from the Definitions Tab.
1. Click on the Definition Tab
GeNIe will display the following dialog:
2. Double-click on the identifier of the first state,, and change its name to Success
3. Similarly rename State1 into Failure .
Now let us enter the probabilities of occurance of each of the states. Initially GeNIe sets the probabilities to 0.5. i.e. both the states are equally likely.
We want to setSuccess to 0.2 and Failure to 0.8. This expresses the fact that on the average 80% of similar new businesses fail.
4. Double click on the value field for the Success state and enter 0.2.
5. Select value field for Failure .
6. Click on the Complement [] button. This will set the value field to 0.8.
The Complement button simply subtracts the sum of the probabilities in the same column from 1 and adds the remainder to the selected field. The sum of the probabilities for our problem was 1 [ Success(0.8) + Failure(0.2) = 1 ] hence we could use the Complement function.
If the sum of probabilities for all the states does not add up to 1.0 then you can use the Normalize [] button to adjust it to 1.
After you are done the tab should look as follows:
We are done defining the properties for this node.
7. Press the OK button to return to the Graph View .
D. Now let us create the node for the variableExpert forecast.
Click on the Chance button and then click below the previously created node in the Graph View .
Your Graph View will look similar to this:
The label for the 'Succ...' node is not completely displayed due to the small size of the node. You can adjust the size of the node to fit the text.
Right click on the node and select Resize to Fit Text from the Node Popup Menu.
The node will become larger and will display the 'Success of the venture' label.
The new node we just created will represent the expert's prediction.
E. In order to represent the fact that the expert's prediction depends on the actual prospects for success, we will create an influence arc between the two nodes.
Click on the ( Arc ) tool (note that the cursor changes), then click on the 'Succ...' node, hold the left mouse button and drag the mouse to the new node (Node2 ), and release the button anywhere within the new node.
GeNIe will draw an arc from 'Success' node to 'Node2'. The diagram will now look as follows:
The arc between the two nodes means that whether or not the venture is going to be successful makes a difference for the probability distribution over various statements made by the expert.
F. Now, let us define the properties of the new node.
1. Double-click on Node2.
2. Change its identifier and name to Forecast and Expert forecast , respectively.
3. Click on the Definition tab.
4. Rename the two states [ State0 & State1 ] to Good and Moderate .
The screen should look as follows:
But the expert's forecast can have three possible values: Good, Moderate, and Poor. We have defined 2 states, Good and Moderate. To define the Poor state we need to add one more state.
Let us add a new state.
5. Click on the Add Outcome [] button. This will add a new state named State2 below the Moderate state.
6. Renaming the newly added state to Poor .
7. Now enter the probabilities for each state combination. Use the values shown below:
The probability table above encodes the conditional probabilities of different expert forecasts for all possible actual prospects of the investment. (In general, a node with parents will encode the distribution of this node for all possible combinations of outcomes of these parents.) For example, the first column encodes our knowledge that if the prospects are good (the venture is going to succeed), the expert will designate it as Good with chance 0.4 (40%), as Moderate with chance 0.4 (40%) and as Bad with a chance 0.2 (20%). Similarly, the second column encodes our knowledge that the expert will designate an eventually failing venture as Good, Moderate, and Poor 10%, 30%, and 60% of the time.
8. Click on OK to return to the Graph View .
You may want to resize the 'Exper...' node so that we can see the entire label.
9. Right click on the node and select Resize to Fit Text from the menu. The node will become larger and will display the Expert Forecast label.
If you want to align the 2 nodes to make the graph look neater, select both the nodes and click on [ Align Left ] button on the Format Toolbar.
Your network should look like this:
G. At this point you should save your work.
1. Click on on the Standard Toolbar .
GeNIe will display the Save As.. dialog shown below:
2. Enter 'Tutorial3 ' as the filename and click on Save .
We will learn later in detail how to load and save models in the Saving and Loading Models tutorial.
Now that your model is saved, we can continue.
Now let us put our model to some work. We can use it to answer the questions posed in the beginning of this tutorial. The first question was "What is the chance for success if the expert judges the prospects for success to be good?"
To answer this question, you will need to tell GeNIe that you have observed a value of the Forecast variable and ask it to update its probability distribution over the variable Success.
1. Right-click on the variable 'Expert Forecast ' and choose Set evidence/Good.
Notice that the status icon on the bottom right of the node changes from to . This indicates that the node has been observed.
2. Click on the Updatetool [
] found on the Standard Toolbar.
This updates the probability distributions in light of observed evidence. Notice that the status icon for the 'Success Of the Venture ' node changes to from .
3. Move the mouse cursor over the for the 'Success...' node.
This will display the posterior probability distribution over the success of the venture shown below:
You will see that expert's forecast Good has changed the probability of Success of the venture from 0.2 to 0.5.
H. To answer the second question: "What if he judges them to be poor?" we will set the evidence in node Expert Forecast to Poor, update the model, and observe that the probability of success is now less than 0.08.
Results of Bayesian updating can be also viewed by double-clicking on a node and selecting the Value tab.
4. Double click on the Success of venture node .
5. Select Value Tab from the Node Properties sheet .
The result in the latter case (expert's prediction Poor), will look as follows:
What we created was a very simple Bayesian network. You can create more complex models in similar ways.
You can find the above model named "tutorial3.xdsl" in the 'Example Networks' directory among other example models that come with GeNIe.
Next Tutorial: