In this exercise we will perform classification with a Bayesian network.
Prerequisites
1 - Bayes Server
Bayes Server must be installed, before starting this walkthrough.
Note |
---|
An evaluation version can be downloaded from the Bayes Server website. |
2 - The Bayesian network 'Identification Extended'
This network is available, from either:
The SampleNetworks folder, that is packaged with the course help
By working through Exercise - construction.
3 - Sql Server Express Database
A Sql Server express database (2008 or later) must be installed, before starting this walkthrough.
Note |
---|
The database must be setup (once) using the database script that accompanies the course notes. |
4 - Data Connection
A data connection to the BSTRX database must have been created. See Exercise - Data Connection.
Open the Bayesian network
Launch Bayes Server and open the Bayesian network IdentificationExtended.bayes located in the SampleNetworks folder, that is packaged with the course help.
Note Alternatively the Bayesian network can be constructed manually in Exercise - construction.
Batch query
Open the Batch Query window by clicking the Batch Query button on the Data tab of the main ribbon toolbar.
This will launch the Data Selection window. Ensure that the Data Connection is set to localhost\sqlexpress (BSTRX), and the Data dropdown is set to IdentificationExtendedTest.
Caution Note that the table used here is different to the training data we used earlier, and has the suffix Test.
Click the Ok button on the Data Selection window, which will launch the Data Map window.
Clear the mapping for the Gender variable, leaving the default settings for the other variables.
Tip To clear a mapping for a variable click the Eraser button next to the variable.
If the Weight drop down has been automatically mapped to the Weight column, set it to map to nothing.
Caution It is important to clear the weight mapping, as the Weight drop down is used to assign a case weight, which is unrelated to the weight variable in our network.
Now click the information tab, and check the Gender information column.
The Data Map tabs should now look like this.
Click the Ok button on the Data Map window. This will launch the Batch Query window.
Click the checkbox next to the following items in the pane on the left of the Batch Query window.
Predict(Gender) PredictProbability(Gender) PredictProbability(Gender = Female) Gender Click the Start button. The Batch Query window should now look like this.
Confusion matrix
To determine how well our model has performed on test data, click the Confusion matrix button on the Statistics tab in the Batch Query ribbon toolbar.
This will launch the Confusion Matrix Options window shown below:
Ensure that Gender and Predict(Gender) are selected.
Click Ok to accept the default choices. This will launch the Confusion Matrix window shown below.
Tip Diagonal elements are correctly classified, off diagonal are incorrectly classified.
Lift chart
If our goal is to identify a particular Gender, we can use a lift chart to determine how well our model performs.
Click the Lift Chart button on the Statistics tab in the Batch Query ribbon toolbar.
This will launch the Lift Chart options window shown below:
Ensure that Gender and PredictProbability(Gender=Female) are selected.
Click Ok to accept the default choices. This will launch the Lift Chart value options window shown below.
Ensure that the target value is Female.
Click Ok to accept the default choices. This will launch the Lift Chart window shown below.