def test4a(self): c = sc.ask('Test', 'Positive', {'Treatment': True, 'Prognosis': 1, 'Genes': False}, BayesTest.bn) print('P(te|tr, p==1, ¬g)=', c) self.assertAlmostEqual(0.37638133353548264, c, places=4)
def test5a(self): c = sc.ask('Cancer', True, {'Treatment': False, 'Prognosis': 3, 'Age': False, 'Genes': True}, BayesTest.bn) print('P(c|¬tr, p==3, ¬a, g)=', c) self.assertAlmostEqual(0.0009581593304489263, c, places=4)
def test3a(self): c = sc.ask('Test', 'Negative', {'Prognosis': 3, 'Age': True}, BayesTest.bn) print('P(¬te|p==3, a)=', c) self.assertAlmostEqual(0.8719779284081078, c, places=4)
def test3b(self): c = sc.ask('Cancer', False, {'Treatment': True, 'Test': 'Positive'}, BayesTest.bn) print('P(c|tr, te)=', c) self.assertAlmostEqual(0.47115384615384615, c, places=4)
def test2h(self): c = sc.ask('Treatment', True, {'Cancer': False}, BayesTest.bn) print('P(tr|¬c)=', c) self.assertAlmostEqual(0.21571064747479804, c, places=4)
def test2i(self): c = sc.ask('Genes', True, {'Prognosis': 3}, BayesTest.bn) print('P(g|p==3)=', c) self.assertAlmostEqual(0.2281383067746976, c, places=4)
def test1f(self): c = sc.ask('Prognosis', 3, {}, BayesTest.bn) print('P(p==3)=', c) self.assertAlmostEqual(0.1319049234366881, c, places=4)
def test2(self): bn = self.makeBurglaryNet() a = ask('Burglar', True, {'JohnCalls': True, 'MaryCalls': True}, bn) print('P(b|j,m)=', a) self.assertAlmostEqual(0.2841718, a)
def test1d(self): c = sc.ask('Test', 'Positive', {}, BayesTest.bn) print('P(te)=', c) self.assertAlmostEqual(0.0416, c)
def test1e(self): c = sc.ask('Treatment', False, {}, BayesTest.bn) print('P(tr)=', c) self.assertAlmostEqual(0.7672, c)
def test5(self): bn = self.makeBurglaryNet() a = ask('Earthquake', False, {'Burglar': True}, bn) print('P(-e)=', a) self.assertAlmostEqual(0.998, a)
def test4(self): bn = self.makeBurglaryNet() a = ask('Alarm', True, {'Burglar': False}, bn) print('P(a|-b)=', a) self.assertAlmostEqual(0.001578, a)
def test3(self): bn = self.makeBurglaryNet() a = ask('Alarm', True, {}, bn) print('P(a)=', a) self.assertAlmostEqual(0.002516442, a)
def test6a(self): c = sc.ask('Test', 'Negative', {'Cancer': False, 'Treatment': True, 'Prognosis': 5, 'Age': False, 'Genes': True}, BayesTest.bn) print('P(¬te|¬c, tr, p==5, ¬a, ¬g)=', c) self.assertAlmostEqual(0.9490936726628768, c, places=4)
def test2g(self): c = sc.ask('Prognosis', 5, {'Age': False}, BayesTest.bn) print('P(p==5|¬a)=', c) self.assertAlmostEqual(0.9482493677603683, c, places=4)
def test1c(self): c = sc.ask('Cancer', True, {}, BayesTest.bn) print('P(c)=', c) self.assertAlmostEqual(0.0224, c)
def test1(self): bn = self.makeBurglaryNet() a = ask('Alarm', True, {'Burglar': True, 'Earthquake': True}, bn) print('P(a|b,e)=', a) self.assertAlmostEqual(0.95, a)