Click here to hide/show the list of notebooks.
☰  LearningAndEssentialGraphs
In [ ]:
%matplotlib inline
from pylab import *
import matplotlib.pyplot as plt

import os

import pyAgrum as gum
import pyAgrum.lib.notebook as gnb


### Compare learning algorithms¶

Essentially MIIC and 3off2 computes the essential graph (CPDAG) from data. Essential graphs are mixed graphs.

In [ ]:
learner=gum.BNLearner(os.path.join("out","sample_asia.csv"))
learner.use3off2()
learner.useNML()
ge3off2=learner.learnMixedStructure()
ge3off2

In [ ]:
learner=gum.BNLearner(os.path.join("out","sample_asia.csv"))
learner.useMIIC()
learner.useNML()
gemiic=learner.learnMixedStructure()
gemiic


For the others methods, it is possible to obtain the essential graph from the learned BN.

In [ ]:
learner=gum.BNLearner(os.path.join("out","sample_asia.csv"))
learner.useGreedyHillClimbing()
bnHC=learner.learnBN()
geHC=gum.EssentialGraph(bnHC)
geHC
gnb.sideBySide(bnHC,geHC)

In [ ]:
learner=gum.BNLearner(os.path.join("out","sample_asia.csv"))
learner.useLocalSearchWithTabuList()
bnTL=learner.learnBN()
geTL=gum.EssentialGraph(bnTL)
geTL
gnb.sideBySide(bnTL,geTL)


Hence we can compare the 4 algorithms.

In [ ]:
gnb.sideBySide(ge3off2,gemiic,bnHC,geHC,bnTL,geTL,
captions=["Essential graph from 3off2",
"Essential graph from miic",
"BayesNet from HC",
"Essential graph from HC",
"BayesNet form TabuList",
"Essential graph from TabuList"])

In [ ]:


In [ ]: