Graphs

The Bayesian Belief Networks used in the tagging system are represented as graphs. In particular they are directed acyclic graphs (DAGs).

Within this project the graphing system will have various requirements placed upon it.

  • Representation of the each nodes random variable.
  • Ability to render out a visual representation of the graph (for use in the dissertation and for debugging purposes).
  • Storing of additional information such as a nodes name.

The initial implementation of this within the project was a bespoke system created from scratch, whilst this worked, the visual representation requirement would have taken extensive work to be of high enough quality for use. To resolve this it was decided to take advantage of the extensive range of packages available for python.

As a result of this research the current implementation is based upon the NetworkX python package which was created by the Los Alamos National Laboratory. It is a package designed for the creation and manipulation of network/graphs. Importantly it has rich support for rendering of the represented graph in a visual form when combined with the matplotlib python package.

In this new implementation I have implemented a method to represent a conditional probability table (CPT), the CPTs are attached as attributes to the nodes in the graph and will be used later for the inference process. As discussed before these need to be able to be rendered out in a human readable form, for use in the dissertation and for debugging purposes. A function has be created to facilitate this.

The result of this work is shown below. The example CPT values and the simple graph structure have been taken from the example in the wikipedia page on Bayesian Networks. They are purely for demonstration purposes and will have no relevance to the actual project.

Bayesian Network

A simple Bayesian network.

And the following is the human readable form of the the CPTs.

T     F  
*********
0.2   0.8   

A   *   T      F   
*******************
F   *   0.4    0.6    
T   *   0.1    0.99   

B   A   *   T      F   
***********************
F   F   *   0.0    1.0    
F   T   *   0.8    0.2    
T   F   *   0.9    0.1    
T   T   *   0.99   0.01

Whilst the example shown here is simple, the implementation can scale to a much larger graph and allows for the performance of inference from the graph represented.

Summary

  • Graph representation has been implemented (once without external packages and once with NetworkX).
  • Rendering to human form of the graph and data contained within it.

Next

Write the code to perform the actual inference from the Bayesian network represented in this work.

Leave a Reply

Your email address will not be published. Required fields are marked *