Identifying the skeleton of a Bayesian network

This demonstration illustrates the skeleton identification process for 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 sample

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

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

Learning the skeleton from the samples

We provide the samples as input to the org.mensxmachina.pgm.mmpcskeleton function, which applies the MMPC algorithm to each of the variables in the dataset. We don't supply any parameter-value pairs so the defaults are used. Note that by default no symmetry correction is performed.

% learn the skeleton
skeleton = org.mensxmachina.pgm.mmpcskeleton(a);
Learning TPC(1)...

Learning TPC(2)...

Learning TPC(3)...

Learning TPC(4)...

Learning TPC(5)...

Learning TPC(6)...

Learning TPC(7)...

Learning TPC(8)...

Learning TPC(9)...

Learning TPC(10)...

Learning TPC(11)...

Learning TPC(12)...

Learning TPC(13)...

Learning TPC(14)...

Learning TPC(15)...

Learning TPC(16)...

Learning TPC(17)...

Learning TPC(18)...

Learning TPC(19)...

Learning TPC(20)...

Learning TPC(21)...

Learning TPC(22)...

Learning TPC(23)...

Learning TPC(24)...

Learning TPC(25)...

Learning TPC(26)...

Learning TPC(27)...

Learning TPC(28)...

Learning TPC(29)...

Learning TPC(30)...

Learning TPC(31)...

Learning TPC(32)...

Learning TPC(33)...

Learning TPC(34)...

Learning TPC(35)...

Learning TPC(36)...

Learning TPC(37)...

Comparing the learned skeleton 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.skeletonperf and we print the sensitivity and specificity. org.mensxmachina.pgm.skeletonperf is a version of the classperf function in the Bioinformatics Toolbox (TM), specialized for skeleton learning. A skeleton learning task can be viewed as a binary classification task where the possible edges are classified as edges (positives) or non-edges (negatives). Finally we plot the confusion matrix with the org.mensxmachina.pgm.plotskeletonconfusion function, which is a version of the plotconfusion function in the Neural Network Toolbox (TM), specialized for skeleton learning.

% get true skeleton
skeleton_true = bnet.skeleton;

% get classifier performance object
cp = org.mensxmachina.pgm.skeletonperf(skeleton_true, skeleton);

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

% plot confusion matrix
org.mensxmachina.pgm.plotskeletonconfusion(skeleton_true, skeleton);
Sensitivity = 95.65%

Specificity = 100.00%