Learning the Whole Skeleton of a Bayesian Network
This demonstration illustrates the skeleton learning process of the example Weather network.
Contents
Loading the True Network
First we load the ALARM network in the org.mensxmachina.bnet.Network object net.
% load ALARM network load mxm_bnet_alarm_net; % loads 'net' Network
Loading the Network Samples
Then we load samples from the ALARM network in dataset a.
% load ALARM network samples load mxm_bnet_alarm_samples; % loads 'a' dataset
Learning the Skeleton from the Samples
We provide the samples as input to the org.mensxmachina.bnet.mmskeleton function, which applies the MMPC-bar algorithm to each of the variables in the dataset. We don't supply any parameter-value pairs so the defaults are used.
% learn the skeleton
skeleton = org.mensxmachina.bnet.mmskeleton(a);
Learning EPC(1)... Learning EPC(2)... Learning EPC(3)... Learning EPC(4)... Learning EPC(5)... Learning EPC(6)... Learning EPC(7)... Learning EPC(8)... Learning EPC(9)... Learning EPC(10)... Learning EPC(11)... Learning EPC(12)... Learning EPC(13)... Learning EPC(14)... Learning EPC(15)... Learning EPC(16)... Learning EPC(17)... Learning EPC(18)... Learning EPC(19)... Learning EPC(20)... Learning EPC(21)... Learning EPC(22)... Learning EPC(23)... Learning EPC(24)... Learning EPC(25)... Learning EPC(26)... Learning EPC(27)... Learning EPC(28)... Learning EPC(29)... Learning EPC(30)... Learning EPC(31)... Learning EPC(32)... Learning EPC(33)... Learning EPC(34)... Learning EPC(35)... Learning EPC(36)... Learning EPC(37)...
Comparing the Learned Skeleton with the True One
Now we compare the learned skeleton with the true Weather skeleton. First we obtain the skeleton of the Weather network by calling the skeleton method of the org.mensxmachina.bnet.Network class. Then we get a classification performance object with org.mensxmachina.bnet.skeletonperf and we print the sensitivity and specificity. org.mensxmachina.bnet.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.bnet.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 = net.skeleton; % get classifier performance object cp = org.mensxmachina.bnet.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.bnet.plotskeletonconfusion(skeleton_true, skeleton);
Sensitivity = 93.48% Specificity = 100.00%
