Learning the parents and children of a Bayesian network node

This demonstration illustrates the parents and children learning process of a node in the ALARM network.

Contents

Loading the true Bayesian network

First we load the ALARM network as an object bnet of the org.mensxmachina.pgm.CategoricalBayesianNetwork class.

% load ALARM network
load mxm_pgm_alarm_bnet; % loads 'bnet' Categorical Bayesian network

Loading the Bayesian network samples

Then we load samples from the ALARM network in dataset a.

% load ALARM network samples
load mxm_pgm_alarm_sample; % loads 'a' dataset

Learning the parents and children of a node from the samples

We provide the samples as input to the org.mensxmachina.pgm.mmpc function in order to learn the parents and children of node #37. We don't set any parameter-value pairs so the defaults are used. Note that by default no symmetry correction is performed.

% learn parents and children set of variable #37
pc = org.mensxmachina.pgm.mmpc(a, 37)
Learning TPC(37)...

Learning TPC(25)...

Learning TPC(31)...

Learning TPC(36)...

pc =

  (36,7)        1
  (25,24)       1
  (24,25)       1
  (26,25)       1
  (37,25)       1
  (25,26)       1
  (31,27)       1
  (36,27)       1
  (31,29)       1
  (27,31)       1
  (29,31)       1
   (7,36)       1
  (27,36)       1
  (37,36)       1
  (25,37)       1
  (36,37)       1

Comparing the learned parents and children set with the true one

Now we compare the learned skeleton with the true ALARM skeleton. First we obtain the skeleton of the ALARM network by calling the skeleton method of the org.mensxmachina.pgm.CategoricalBayesianNetwork class. Then we get a classification performance object with org.mensxmachina.pgm.pcperf and we print the sensitivity and specificity. org.mensxmachina.pgm.pcperf is a version of the classperf function in the Bioinformatics Toolbox (TM), specialized for skeleton learning. For a given node, the task of learning its parents and children can be viewed as a binary classification task, where each other node is classified as either parent or child, or not. Finally we plot the confusion matrix with the org.mensxmachina.pgm.plotpcconfusion function, which is a version of the plotconfusion function in the Neural Network Toolbox (TM) specialized for parents and children learning. We see that we learned the parents and children of node #37 correctly.

% get true skeleton
skeleton_true = bnet.skeleton;

% get classifier performance object for variable #37
cp = org.mensxmachina.pgm.pcperf(skeleton_true, pc, 37);

% print sensitivity and specificity
fprintf('\nSensitivity = %.2f%%\n', cp.sensitivity*100);
fprintf('\nSpecificity = %.2f%%\n', cp.specificity*100);

% plot confusion matrix for variable #37
org.mensxmachina.pgm.plotpcconfusion(skeleton_true, pc, 37);
Sensitivity = 100.00%

Specificity = 100.00%