def setUp(self): from bayesnet import BNet, BVertex, graph # create a small BayesNet G = BNet('Water Sprinkler Bayesian Network') c,s,r,w = [G.add_v(BVertex(nm, discrete=True, nvalues=nv)) for nm, nv \ in zip('c s r w'.split(), [2, 3, 4, 2])] for ep in [(c, r), (c, s), (r, w), (s, w)]: G.add_e(graph.DirEdge(len(G.e), *ep)) G.InitDistributions() self.G = G
def setUp(self): from bayesnet import BNet, BVertex, graph # create a small BayesNet, Water-Sprinkler G = BNet('Test') a, b, c, d = [G.add_v(BVertex(nm, discrete=True, nvalues=nv)) for \ nm, nv in zip('a b c d'.split(), [2, 3, 4, 2])] ad, bd, cd, dd = a.distribution, b.distribution, \ c.distribution, d.distribution # sizes = (2,3,4,2) # a has 3 parents, b,c and d for ep in [(b, a), (c, a), (d, a)]: G.add_e(graph.DirEdge(len(G.e), *ep)) G.InitDistributions() self.G = G self.a, self.b, self.c, self.d = a, b, c, d