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:

  1. The SampleNetworks folder, that is packaged with the course help

  2. 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

  1. 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.

  2. Click the Ok button on the Data Selection window, which will launch the Data Map window.

  3. 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.

  4. 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.

  5. Now click the information tab, and check the Gender information column.

    The Data Map tabs should now look like this.

    Exercise Classification Data Map No Gender
    Exercise Classification Data Map Information
  6. Click the Ok button on the Data Map window. This will launch the Batch Query window.

  7. 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
  8. Click the Start button. The Batch Query window should now look like this.

    Exercise Classification Batch Query

Confusion matrix

  1. 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.

    Exercise Classification Confusion Matrix Options
  2. Click Ok to accept the default choices. This will launch the Confusion Matrix window shown below.

    Exercise Classification Confusion Matrix
    Tip

    Diagonal elements are correctly classified, off diagonal are incorrectly classified.

Lift chart

  1. 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.

    Exercise Classification Lift Chart Options
  2. 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.

    Exercise Classification Lift Chart Value Options
  3. Click Ok to accept the default choices. This will launch the Lift Chart window shown below.

    Exercise Classification Lift Chart