Contents   |   Previous   |   Next


4. Building a bayesian network using Bayonet Editor

Let us use the Bayonet System GUI and walk through constructing a bayesian network that learns from the experience data stored in a CSV file. In this example, we will use the Bayonet editor to construct the model. If you wish to use the wizard, please check out the chapter, Building a bayesian network using Model Construction Wizard.

Before continuing with this tutorial, you may wish to get familiar with the Bayonet GUI and objects and functions of Bayonet Sytem.

Requirements

In order to construct the bayesian network from experience data, we need to have the data captured already. Let us take for example, the data about user's impression on some images and information about the user. Say we have about 550 users answered a questionaire, which has different questions with different parameters on 5 images. Users have selected one out of 4 different options for each question. We also record the information about the user like, age, sex, job and area of the user. Now from this information let us construct a bayesian network.

Let us call the table user_imp which has the columns, user_id, q1_1_1, q1_1_2, q1_1_3, ..., q1_1_11, q1_2_1, q1_2_2, q1_2_3, ..., q1_2_11, q1_3_1, q1_3_2, ..., q1_3_11, q2_1_1, ..., q5_3_11, area, agetype, age, sex and job. This table has to be created on a database system having JDBC driver or the data can be on a CSV file. Bayonet System can work with either of these types.

Modify the attributes in the file db.xml under Bayonet System directory/ properties/ xml/ db, if you are using Database DST. If you are using the simple File DST of the Bayonet System, you should have the user_imp.csv file ready.

Note that you can get this data with the Bayonet System when you download the system. You can also construct the table or CSV file with the data, yourself. Since we are taking only one child for this tutorial, it is not necessary to have all the fields mentioned above. The required fields to follow this sample are agetype, job and q1_1_1.

You can use the Data Preparation Wizard, to edit the existing sample data and prepare a data file of your need.

Creating bayesian network

It is assumed that you have successfully installed the Bayonet System. If you have not installed the Bayonet System, please do so before continuing.

Open the Bayonet GUI
Use the batch file, bayonet.bat to launch the Bayonet System.

Create New Project
Select 'New' from the 'File' menu or click on the 'New bayonet project' button on the toolbar. Fill in the project name, path and description as shown in the picture.

Click 'OK' and confirm to create the directory, if prompted.

Now you can see the project directory is created in the name of the project, Sample. The new project, Sample is the current project and the editor is opened for the same.

Create Nodes
Now you can create nodes. Before that, you need to decide on the nodes that should be part of the bayesian network that we are going to construct. Let us take agetype, job and q1_1_1 as the nodes for our Sample project.

Select 'Create Node' from the 'Edit' menu or click on the 'Create Node' button on the toolbar. Fill in the 'Create Node' dialogue box as shown in the picture for the node, AgeType.

Similarly, create two more nodes for Job and q1_1_1.

Create Tree
Now, let us link the nodes, creating a tree. We are going to analyse whether the user's impression on an image depends on the factors, age type or job of the user. So, we should create a tree on the node, q1_1_1 and link the nodes AgeType and Job to q1_1_1.
Right click on the node, q1_1_1 and add tree to the node.

Select 'Create Link' from the 'Edit' menu or click on the 'Create Link' button on the toolbar. Select AgeType and Job from the Start Node list. By default the only possible End Node, q1_1_1 is displayed in the End Node list. Click OK. Now the nodes are linked.

Create DST
Let us get the experience data to calculate the CPT values for the tree, we have created.
Click on the tree node, q1_1_1 and select the tab, DST from the information panel.
Select the database type as 'FileDST' and click on 'Create' button.
Click on the search button next to the 'File data' text box to select the CSV file, user_imp.csv.
The list of items from the file is displayed. Now select the items Agetype, Job and q1_1_1 and assign to the nodes AgeType, Job and q1_1_1 respectively. To assign the item to the appropriate node, press the right mouse button on an item in the item list and forward the item to the appropriate node on the popup menu. The System updates the input and output information (parent and child nodes) as the items are assigned to nodes.

Click on 'Update DST' button. This updates the names of the nodes. Click on 'DST to CPT' button. The system counts the repetition of values for each item and prepares the CPT values.

Normalise CPT
Select the CPT information panel and take a look on the CPT values displayed in the CPT Monitor. You will find the number of users selected the the four answers for the question, q1_1_1 for the combination of 13 age groups and 19 job types. You may find some columns displaying the values 'miss'. This means for that combination there is no data found in the file.
Click on the button 'N' to normalise the data to calculate the conditional probability. Then, calculate the entropy by clicking on the button 'E'.

Select Best Tree
Now you can use the Bayonet System to do an analysis and find out which is the most dominating factor. Whether the user's age group plays a role on his ipression on an image? Whether the job factor makes users think differently? or both or none, etc.
Select the tree node, q1_1_1. Right click to get the pop-up menu and select 'Decompose all possible trees'.
Select the Tree Selector panel on the information panel tabs. Select an algorithm from the tree selector list.
Click on 'Watch All Trees' to view the trees. Click on 'Select' button to select the best tree, the result of such analysis by the Bayonet System.

Save Project
Save this project using 'Save' from the 'File' menu. You can save this as a Hugin net file using the 'Save Net File' command from 'File' menu.



Contents   |   Previous   |   Next