Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Detailed Description

Shikhar Nigam edited this page Oct 30, 2013 · 10 revisions
  1. Introduction ================ pgmpy_viz is the GUI application implementing the library pgmpy - a library for probabilistic graphical modelling in Python. The GUI allows us to:

  2. create nodes and label them

  3. add edges between nodes

  4. add tabular CPD to each node

  5. toggle the "observed-status" of a node

  6. view the CPD of a node

  7. Modes in pgmpy_viz =====================

  • The GUI contains two modes, viz. the Draw Mode and the Analysis Mode and appropriate buttons to toggle between the two.

  • The Draw Mode is statically programmed.

  • The Analysis Mode is dynamically programmed.

2.1. Draw Mode

Upon clicking the Draw Mode button, we enter the "draw state". Here, two more buttons appear below Draw Mode and Analysis Mode:

  1. Add Nodes : Takes us into "adding nodes state"
  2. Add Edges : Takes us into "adding edges state"

2.1.1 Adding Nodes

  1. Click on Add Nodes : Program enters "adding nodes"-state and the Add Nodes button changes to Stop Adding Nodes

  2. Once, the Add Nodes button has been clicked, a single-click anywhere in the pane, creates a Node. A text-box is shown for the name (input) of the Node-label. (Only the first six-letters of the Label are shown against the node when it is unselected). It is a compulsory field. The maximum length of name can be 20 characters.

  3. Whilst still in the "adding nodes" state, step 2 may be repeated as many times as required - each time a new node being created.

  4. When adding nodes has been finished, click on the Stop Adding Nodes button to exit the "adding node" state. The button changes back to Add Nodes.

2.1.2 Adding Edges

  1. Click on Add Edges : Program enters "adding edges"-state and the Add Edges button changes to Stop Adding Edges

  2. Once, the Add Edges button has been clicked, the first single-click on a node and a second single-click on another node, creates a directed edge between them from the first-clicked Node to the second-clicked Node. Self-loops are not allowed. Multiple edges between two nodes are not allowed.

  3. Whilst still in the "adding edges" state, step 2 may be repeated as many times as required - each time a new edge being created.

  4. When adding edges has been finished, click on the Stop Adding Edges button to exit the "adding edge" state. The button changes back to Add Edges.

2.1.3 Draw-State

  • This is the state where none of the two buttons have been pressed.
  • Mouse-hover over any Node reveals its full-name.
  • In this state, double-clicking a Node, should open up its Tabular-CPD in read-write mode. The structure of a tabular CPD is given below:

Tabular CPD

  • The table has one more row at the top, showing name of the Node (this detail is missing in the illustrative image).
  • If a node is a child, then Tabular CPD automatically contains the names of the Parents and the states present in the Parents and its own name (as given during the "add nodes" state)
  • For each node, its own states, its own name and the probability-values in the table is editable.

2.1.4 Posting The Model

  • The Tabular CPD of each node has an OK and Cancel button. The tabular CPD is displayed at the bottom of page.
  • Upon entering the probabilities in the table, OK is pressed. This validates the model to be complete and correct. If it is, the model is pushed onto the server in JSON.
  • The JSON object should have a structure as shown below:
{
    adjacency_matrix:[[],[]],
   'Node1':[['State1.1', 'State1.2'], ['Parent1.1', 'Parent1.2'], [CPD1]],
   'Node2':[['State2.1', 'State2.2'], ['Parent2.1', 'Parent2.2'], [CPD2]]
} 
  • [CPD1], [CPD2] etc. are 2-D arrays.
Clone this wiki locally