Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- y.factors.Factor.Factor object>]), 'L': set([<pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>]), 'R': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>])}
- var.remove = undefined
- factor = <pgmpy.factors.Factor.Factor object>
- 16 working_factors[var].add(factor_reduced)
- 17 del working_factors[evidence_var]
- 18
- 19 def _variable_elimination(self, variables, operation, evidence=None, elimination_order=None):
- KeyError: 'J'
- ___________________________________________________________________________
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/tests/test_inference/test_ExactInference.py", line 86, in test_map_query_with_evidence
- {'J': 0, 'Q': 1, 'G': 0})
- File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py", line 188, in map_query
- elimination_order=elimination_order)
- File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py", line 50, in _variable_elimination
- Parallel(n_jobs=-1, backend="threading") (delayed(self. parallelFor)(evidence_var,working_factors,evidence)for evidence_var in evidence)
- File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 660, in __call__
- self.retrieve()
- File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 543, in retrieve
- raise exception_type(report)
- joblib.my_exceptions.JoblibKeyError: JoblibKeyError
- ___________________________________________________________________________
- Multiprocessing exception:
- ...........................................................................
- /usr/bin/nosetests3 in <module>()
- 4 import sys
- 5 from pkg_resources import load_entry_point
- 6
- 7 if __name__ == '__main__':
- 8 sys.exit(
- ----> 9 load_entry_point('nose==1.3.1', 'console_scripts', 'nosetests')()
- 10 )
- 11
- 12
- 13
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/core.py in __init__(self=<nose.core.TestProgram object>, module=None, defaultTest='.', argv=None, testRunner=None, testLoader=None, env=environ({'SESSION_MANAGER': 'local/gokstudio:@/t...ault.path', 'KONSOLE_DBUS_WINDOW': '/Windows/2'}), config=Config(addPaths=True, args=(), configSection='no...r=False, workingDir='/home/gokul/pgmpy_gk/pgmpy'), suite=None, exit=True, plugins=None, addplugins=None)
- 116 if version >= (2,7) and version != (3,0):
- 117 extra_args['exit'] = exit
- 118 unittest.TestProgram.__init__(
- 119 self, module=module, defaultTest=defaultTest,
- 120 argv=argv, testRunner=testRunner, testLoader=testLoader,
- --> 121 **extra_args)
- extra_args = {'exit': True}
- 122
- 123 def getAllConfigFiles(self, env=None):
- 124 env = env or {}
- 125 if env.get('NOSE_IGNORE_CONFIG_FILES', False):
- ...........................................................................
- /usr/lib/python3.4/unittest/main.py in __init__(self=<nose.core.TestProgram object>, module=None, defaultTest='.', argv=['/usr/bin/nosetests3'], testRunner=None, testLoader=None, exit=True, verbosity=1, failfast=None, catchbreak=None, buffer=None, warnings=None)
- 88 self.defaultTest = defaultTest
- 89 self.testRunner = testRunner
- 90 self.testLoader = testLoader
- 91 self.progName = os.path.basename(argv[0])
- 92 self.parseArgs(argv)
- ---> 93 self.runTests()
- self.runTests = <bound method TestProgram.runTests of <nose.core.TestProgram object>>
- 94
- 95 def usageExit(self, msg=None):
- 96 if msg:
- 97 print(msg)
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/core.py in runTests(self=<nose.core.TestProgram object>)
- 202 verbosity=self.config.verbosity,
- 203 config=self.config)
- 204 plug_runner = self.config.plugins.prepareTestRunner(self.testRunner)
- 205 if plug_runner is not None:
- 206 self.testRunner = plug_runner
- --> 207 result = self.testRunner.run(self.test)
- result = undefined
- self.testRunner.run = <bound method TextTestRunner.run of <nose.core.TextTestRunner object>>
- self.test = <nose.suite.ContextSuite context=None>
- 208 self.success = result.wasSuccessful()
- 209 if self.exit:
- 210 sys.exit(not self.success)
- 211 return self.success
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/core.py in run(self=<nose.core.TextTestRunner object>, test=<nose.suite.ContextSuite context=None>)
- 57 self.stream = wrapped
- 58
- 59 result = self._makeResult()
- 60 start = time.time()
- 61 try:
- ---> 62 test(result)
- test = <nose.suite.ContextSuite context=None>
- result = <nose.result.TextTestResult run=102 errors=0 failures=0>
- 63 except KeyboardInterrupt:
- 64 pass
- 65 stop = time.time()
- 66 result.printErrors()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=None>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=None>>
- arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=None>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = <nose.suite.LazySuite tests=generator (139974360407624)>
- orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/lib/python3.4/unittest/suite.py in __call__(self=<nose.suite.LazySuite tests=generator (139974360407624)>, *args=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kwds={})
- 82 if hasattr(test, 'countTestCases'):
- 83 self._removed_tests += test.countTestCases()
- 84 self._tests[index] = None
- 85
- 86 def __call__(self, *args, **kwds):
- ---> 87 return self.run(*args, **kwds)
- self.run = <bound method LazySuite.run of <nose.suite.LazySuite tests=generator (139974360407624)>>
- args = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
- kwds = {}
- 88
- 89 def debug(self):
- 90 """Run the tests without collecting errors in a TestResult"""
- 91 for test in self:
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.LazySuite tests=generator (139974360407624)>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
- 71 # added to bypass run changes in 2.7's unittest
- 72 def run(self, result):
- 73 for test in self._tests:
- 74 if result.shouldStop:
- 75 break
- ---> 76 test(result)
- test = <nose.suite.ContextSuite context=pgmpy>
- result = <nose.result.TextTestResult run=102 errors=0 failures=0>
- 77 return result
- 78
- 79 def __bool__(self):
- 80 log.debug("tests in %s?", id(self))
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy>>
- arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = <nose.suite.ContextSuite context=pgmpy.tests>
- orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy.tests>>
- arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = <nose.suite.ContextSuite context=pgmpy.tests.test_inference>
- orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy.tests.test_inference>>
- arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = <nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>
- orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.Co...=pgmpy.tests.test_inference.test_ExactInference>>
- arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = <nose.suite.ContextSuite context=TestVariableElimination>
- orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=TestVariableElimination>, *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=TestVariableElimination>>
- arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=TestVariableElimination>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = Test(<pgmpy.tests.test_inference.test_ExactInfer...ination testMethod=test_map_query_with_evidence>)
- orig = <nose.result.TextTestResult run=102 errors=0 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/case.py in __call__(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...ination testMethod=test_map_query_with_evidence>), *arg=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kwarg={})
- 41 self.plugins = config.plugins
- 42 self.passed = None
- 43 unittest.TestCase.__init__(self)
- 44
- 45 def __call__(self, *arg, **kwarg):
- ---> 46 return self.run(*arg, **kwarg)
- self.run = <bound method Test.run of Test(<pgmpy.tests.test...nation testMethod=test_map_query_with_evidence>)>
- arg = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
- kwarg = {}
- 47
- 48 def __str__(self):
- 49 name = self.plugins.testName(self)
- 50 if name is not None:
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/case.py in run(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...ination testMethod=test_map_query_with_evidence>), result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
- 129 if self.resultProxy:
- 130 result = self.resultProxy(result, self)
- 131 try:
- 132 try:
- 133 self.beforeTest(result)
- --> 134 self.runTest(result)
- self.runTest = <bound method Test.runTest of Test(<pgmpy.tests....nation testMethod=test_map_query_with_evidence>)>
- result = <nose.result.TextTestResult run=102 errors=0 failures=0>
- 135 except KeyboardInterrupt:
- 136 raise
- 137 except:
- 138 err = sys.exc_info()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/case.py in runTest(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...ination testMethod=test_map_query_with_evidence>), result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
- 147 """
- 148 test = self.test
- 149 plug_test = self.config.plugins.prepareTestCase(self)
- 150 if plug_test is not None:
- 151 test = plug_test
- --> 152 test(result)
- test = <pgmpy.tests.test_inference.test_ExactInference....mination testMethod=test_map_query_with_evidence>
- result = <nose.result.TextTestResult run=102 errors=0 failures=0>
- 153
- 154 def shortDescription(self):
- 155 desc = self.plugins.describeTest(self)
- 156 if desc is not None:
- ...........................................................................
- /usr/lib/python3.4/unittest/case.py in __call__(self=<pgmpy.tests.test_inference.test_ExactInference....mination testMethod=test_map_query_with_evidence>, *args=(<nose.result.TextTestResult run=102 errors=0 failures=0>,), **kwds={})
- 617 # return this for backwards compatibility
- 618 # even though we no longer us it internally
- 619 return outcome.success
- 620
- 621 def __call__(self, *args, **kwds):
- --> 622 return self.run(*args, **kwds)
- self.run = <bound method TestVariableElimination.run of <pg...ination testMethod=test_map_query_with_evidence>>
- args = (<nose.result.TextTestResult run=102 errors=0 failures=0>,)
- kwds = {}
- 623
- 624 def debug(self):
- 625 """Run the test without collecting errors in a TestResult"""
- 626 self.setUp()
- ...........................................................................
- /usr/lib/python3.4/unittest/case.py in run(self=<pgmpy.tests.test_inference.test_ExactInference....mination testMethod=test_map_query_with_evidence>, result=<nose.result.TextTestResult run=102 errors=0 failures=0>)
- 569 with outcome.testPartExecutor(self):
- 570 self.setUp()
- 571 if outcome.success:
- 572 outcome.expecting_failure = expecting_failure
- 573 with outcome.testPartExecutor(self, isTest=True):
- --> 574 testMethod()
- testMethod = <bound method TestVariableElimination.test_map_q...ination testMethod=test_map_query_with_evidence>>
- 575 outcome.expecting_failure = False
- 576 with outcome.testPartExecutor(self):
- 577 self.tearDown()
- 578
- ...........................................................................
- /home/gokul/pgmpy_gk/pgmpy/pgmpy/tests/test_inference/test_ExactInference.py in test_map_query_with_evidence(self=<pgmpy.tests.test_inference.test_ExactInference....mination testMethod=test_map_query_with_evidence>)
- 81 self.assertDictEqual(map_query, {'A': 1, 'R': 1, 'J': 1, 'Q': 1, 'G': 0,
- 82 'L': 0})
- 83
- 84 def test_map_query_with_evidence(self):
- 85 map_query = self.bayesian_inference.map_query(['A', 'R', 'L'],
- ---> 86 {'J': 0, 'Q': 1, 'G': 0})
- 87 self.assertDictEqual(map_query, {'A': 1, 'R': 0, 'L': 0})
- 88
- 89
- 90 class TestBeliefPropagation(unittest.TestCase):
- ...........................................................................
- /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in map_query(self=<pgmpy.inference.ExactInference.VariableElimination object>, variables=['A', 'R', 'L'], evidence={'G': 0, 'J': 0, 'Q': 1}, elimination_order=None)
- 183 >>> phi_query = inference.map_query(['A', 'B'])
- 184 """
- 185 elimination_variables = set(self.variables) - set(evidence.keys()) if evidence else set()
- 186 final_distribution = self._variable_elimination(elimination_variables, 'maximize',
- 187 evidence=evidence,
- --> 188 elimination_order=elimination_order)
- elimination_order = None
- 189 # To handle the case when no argument is passed then
- 190 # _variable_elimination returns a dict.
- 191 if isinstance(final_distribution, dict):
- 192 final_distribution = final_distribution.values()
- ...........................................................................
- /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in _variable_elimination(self=<pgmpy.inference.ExactInference.VariableElimination object>, variables=set(['A', 'L', 'R']), operation='maximize', evidence={'G': 0, 'J': 0, 'Q': 1}, elimination_order=None)
- 45 for node in self.factors}
- 46
- 47 # Dealing with evidence. Reducing factors over it before VE is run.
- 48
- 49 if evidence: #Implementation of a parallel looping construct
- ---> 50 Parallel(n_jobs=-1, backend="threading") (delayed(self. parallelFor)(evidence_var,working_factors,evidence)for evidence_var in evidence)
- self.parallelFor = <bound method VariableElimination.parallelFor of...rence.ExactInference.VariableElimination object>>
- evidence = {'G': 0, 'J': 0, 'Q': 1}
- 51 # TODO: Modify it to find the optimal elimination order
- 52 if not elimination_order:
- 53 elimination_order = list(set(self.variables) -
- 54 set(variables) -
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/joblib/parallel.py in __call__(self=Parallel(n_jobs=-1), iterable=<generator object <genexpr>>)
- 655 if pre_dispatch == "all" or n_jobs == 1:
- 656 # The iterable was consumed all at once by the above for loop.
- 657 # No need to wait for async callbacks to trigger to
- 658 # consumption.
- 659 self._iterating = False
- --> 660 self.retrieve()
- self.retrieve = <bound method Parallel.retrieve of Parallel(n_jobs=-1)>
- 661 # Make sure that we get a last message telling us we are done
- 662 elapsed_time = time.time() - self._start_time
- 663 self._print('Done %3i out of %3i | elapsed: %s finished',
- 664 (len(self._output),
- ---------------------------------------------------------------------------
- Sub-process traceback:
- ---------------------------------------------------------------------------
- KeyError Fri Mar 6 23:06:30 2015
- PID: 19709 Python 3.4.0: /usr/bin/python3
- ...........................................................................
- /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in parallelFor(self=<pgmpy.inference.ExactInference.VariableElimination object>, evidence_var='G', working_factors={'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'G': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'L': set([<pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>]), 'R': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>])}, evidence={'G': 0, 'J': 0, 'Q': 1})
- 10 def parallelFor(self, evidence_var,working_factors,evidence):
- 11
- 12 for factor in working_factors[evidence_var]:
- 13 factor_reduced = factor.reduce('{evidence_var}_{state}'.format(evidence_var=evidence_var,state=evidence[evidence_var]),inplace=False)
- 14 for var in factor_reduced.scope():
- ---> 15 working_factors[var].remove(factor)
- working_factors = {'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'G': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'L': set([<pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>]), 'R': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>])}
- var.remove = undefined
- factor = <pgmpy.factors.Factor.Factor object>
- 16 working_factors[var].add(factor_reduced)
- 17 del working_factors[evidence_var]
- 18
- 19 def _variable_elimination(self, variables, operation, evidence=None, elimination_order=None):
- KeyError: 'J'
- ___________________________________________________________________________
- ======================================================================
- ERROR: test_query_multiple_variable_with_evidence (pgmpy.tests.test_inference.test_ExactInference.TestVariableElimination)
- ----------------------------------------------------------------------
- Traceback (most recent call last):
- File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 92, in __call__
- return self.func(*args, **kwargs)
- File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py", line 15, in parallelFor
- working_factors[var].remove(factor)
- KeyError: <pgmpy.factors.Factor.Factor object at 0x7f4e4a966400>
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 512, in retrieve
- self._output.append(job.get())
- File "/usr/lib/python3.4/multiprocessing/pool.py", line 599, in get
- raise self._value
- File "/usr/lib/python3.4/multiprocessing/pool.py", line 119, in worker
- result = (True, func(*args, **kwds))
- File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 102, in __call__
- raise TransportableException(text, e_type)
- joblib.my_exceptions.TransportableException: TransportableException
- ___________________________________________________________________________
- KeyError Fri Mar 6 23:06:30 2015
- PID: 19709 Python 3.4.0: /usr/bin/python3
- ...........................................................................
- /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in parallelFor(self=<pgmpy.inference.ExactInference.VariableElimination object>, evidence_var='A', working_factors={'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'J': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>])}, evidence={'A': 0, 'G': 0, 'L': 1, 'R': 0})
- 10 def parallelFor(self, evidence_var,working_factors,evidence):
- 11
- 12 for factor in working_factors[evidence_var]:
- 13 factor_reduced = factor.reduce('{evidence_var}_{state}'.format(evidence_var=evidence_var,state=evidence[evidence_var]),inplace=False)
- 14 for var in factor_reduced.scope():
- ---> 15 working_factors[var].remove(factor)
- working_factors = {'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'J': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>])}
- var.remove = undefined
- factor = <pgmpy.factors.Factor.Factor object>
- 16 working_factors[var].add(factor_reduced)
- 17 del working_factors[evidence_var]
- 18
- 19 def _variable_elimination(self, variables, operation, evidence=None, elimination_order=None):
- KeyError: <pgmpy.factors.Factor.Factor object at 0x7f4e4a966400>
- ___________________________________________________________________________
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/tests/test_inference/test_ExactInference.py", line 59, in test_query_multiple_variable_with_evidence
- 'G': 0, 'L': 1})
- File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py", line 115, in query
- evidence=evidence, elimination_order=elimination_order)
- File "/home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py", line 50, in _variable_elimination
- Parallel(n_jobs=-1, backend="threading") (delayed(self. parallelFor)(evidence_var,working_factors,evidence)for evidence_var in evidence)
- File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 660, in __call__
- self.retrieve()
- File "/usr/local/lib/python3.4/dist-packages/joblib/parallel.py", line 543, in retrieve
- raise exception_type(report)
- joblib.my_exceptions.JoblibKeyError: JoblibKeyError
- ___________________________________________________________________________
- Multiprocessing exception:
- ...........................................................................
- /usr/bin/nosetests3 in <module>()
- 4 import sys
- 5 from pkg_resources import load_entry_point
- 6
- 7 if __name__ == '__main__':
- 8 sys.exit(
- ----> 9 load_entry_point('nose==1.3.1', 'console_scripts', 'nosetests')()
- 10 )
- 11
- 12
- 13
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/core.py in __init__(self=<nose.core.TestProgram object>, module=None, defaultTest='.', argv=None, testRunner=None, testLoader=None, env=environ({'SESSION_MANAGER': 'local/gokstudio:@/t...ault.path', 'KONSOLE_DBUS_WINDOW': '/Windows/2'}), config=Config(addPaths=True, args=(), configSection='no...r=False, workingDir='/home/gokul/pgmpy_gk/pgmpy'), suite=None, exit=True, plugins=None, addplugins=None)
- 116 if version >= (2,7) and version != (3,0):
- 117 extra_args['exit'] = exit
- 118 unittest.TestProgram.__init__(
- 119 self, module=module, defaultTest=defaultTest,
- 120 argv=argv, testRunner=testRunner, testLoader=testLoader,
- --> 121 **extra_args)
- extra_args = {'exit': True}
- 122
- 123 def getAllConfigFiles(self, env=None):
- 124 env = env or {}
- 125 if env.get('NOSE_IGNORE_CONFIG_FILES', False):
- ...........................................................................
- /usr/lib/python3.4/unittest/main.py in __init__(self=<nose.core.TestProgram object>, module=None, defaultTest='.', argv=['/usr/bin/nosetests3'], testRunner=None, testLoader=None, exit=True, verbosity=1, failfast=None, catchbreak=None, buffer=None, warnings=None)
- 88 self.defaultTest = defaultTest
- 89 self.testRunner = testRunner
- 90 self.testLoader = testLoader
- 91 self.progName = os.path.basename(argv[0])
- 92 self.parseArgs(argv)
- ---> 93 self.runTests()
- self.runTests = <bound method TestProgram.runTests of <nose.core.TestProgram object>>
- 94
- 95 def usageExit(self, msg=None):
- 96 if msg:
- 97 print(msg)
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/core.py in runTests(self=<nose.core.TestProgram object>)
- 202 verbosity=self.config.verbosity,
- 203 config=self.config)
- 204 plug_runner = self.config.plugins.prepareTestRunner(self.testRunner)
- 205 if plug_runner is not None:
- 206 self.testRunner = plug_runner
- --> 207 result = self.testRunner.run(self.test)
- result = undefined
- self.testRunner.run = <bound method TextTestRunner.run of <nose.core.TextTestRunner object>>
- self.test = <nose.suite.ContextSuite context=None>
- 208 self.success = result.wasSuccessful()
- 209 if self.exit:
- 210 sys.exit(not self.success)
- 211 return self.success
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/core.py in run(self=<nose.core.TextTestRunner object>, test=<nose.suite.ContextSuite context=None>)
- 57 self.stream = wrapped
- 58
- 59 result = self._makeResult()
- 60 start = time.time()
- 61 try:
- ---> 62 test(result)
- test = <nose.suite.ContextSuite context=None>
- result = <nose.result.TextTestResult run=108 errors=1 failures=0>
- 63 except KeyboardInterrupt:
- 64 pass
- 65 stop = time.time()
- 66 result.printErrors()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=None>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=None>>
- arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=None>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = <nose.suite.LazySuite tests=generator (139974360407624)>
- orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/lib/python3.4/unittest/suite.py in __call__(self=<nose.suite.LazySuite tests=generator (139974360407624)>, *args=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kwds={})
- 82 if hasattr(test, 'countTestCases'):
- 83 self._removed_tests += test.countTestCases()
- 84 self._tests[index] = None
- 85
- 86 def __call__(self, *args, **kwds):
- ---> 87 return self.run(*args, **kwds)
- self.run = <bound method LazySuite.run of <nose.suite.LazySuite tests=generator (139974360407624)>>
- args = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
- kwds = {}
- 88
- 89 def debug(self):
- 90 """Run the tests without collecting errors in a TestResult"""
- 91 for test in self:
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.LazySuite tests=generator (139974360407624)>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
- 71 # added to bypass run changes in 2.7's unittest
- 72 def run(self, result):
- 73 for test in self._tests:
- 74 if result.shouldStop:
- 75 break
- ---> 76 test(result)
- test = <nose.suite.ContextSuite context=pgmpy>
- result = <nose.result.TextTestResult run=108 errors=1 failures=0>
- 77 return result
- 78
- 79 def __bool__(self):
- 80 log.debug("tests in %s?", id(self))
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy>>
- arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = <nose.suite.ContextSuite context=pgmpy.tests>
- orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy.tests>>
- arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = <nose.suite.ContextSuite context=pgmpy.tests.test_inference>
- orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=pgmpy.tests.test_inference>>
- arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = <nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>
- orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.Co...=pgmpy.tests.test_inference.test_ExactInference>>
- arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=pgmpy.tests.test_inference.test_ExactInference>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = <nose.suite.ContextSuite context=TestVariableElimination>
- orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in __call__(self=<nose.suite.ContextSuite context=TestVariableElimination>, *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kw={})
- 173 def __hash__(self):
- 174 return object.__hash__(self)
- 175
- 176 # 2.3 compat -- force 2.4 call sequence
- 177 def __call__(self, *arg, **kw):
- --> 178 return self.run(*arg, **kw)
- self.run = <bound method ContextSuite.run of <nose.suite.ContextSuite context=TestVariableElimination>>
- arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
- kw = {}
- 179
- 180 def exc_info(self):
- 181 """Hook for replacing error tuple output
- 182 """
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/suite.py in run(self=<nose.suite.ContextSuite context=TestVariableElimination>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
- 220 log.debug("stopping")
- 221 break
- 222 # each nose.case.Test will create its own result proxy
- 223 # so the cases need the original result, to avoid proxy
- 224 # chains
- --> 225 test(orig)
- test = Test(<pgmpy.tests.test_inference.test_ExactInfer...thod=test_query_multiple_variable_with_evidence>)
- orig = <nose.result.TextTestResult run=108 errors=1 failures=0>
- 226 finally:
- 227 self.has_run = True
- 228 try:
- 229 self.tearDown()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/case.py in __call__(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...thod=test_query_multiple_variable_with_evidence>), *arg=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kwarg={})
- 41 self.plugins = config.plugins
- 42 self.passed = None
- 43 unittest.TestCase.__init__(self)
- 44
- 45 def __call__(self, *arg, **kwarg):
- ---> 46 return self.run(*arg, **kwarg)
- self.run = <bound method Test.run of Test(<pgmpy.tests.test...hod=test_query_multiple_variable_with_evidence>)>
- arg = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
- kwarg = {}
- 47
- 48 def __str__(self):
- 49 name = self.plugins.testName(self)
- 50 if name is not None:
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/case.py in run(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...thod=test_query_multiple_variable_with_evidence>), result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
- 129 if self.resultProxy:
- 130 result = self.resultProxy(result, self)
- 131 try:
- 132 try:
- 133 self.beforeTest(result)
- --> 134 self.runTest(result)
- self.runTest = <bound method Test.runTest of Test(<pgmpy.tests....hod=test_query_multiple_variable_with_evidence>)>
- result = <nose.result.TextTestResult run=108 errors=1 failures=0>
- 135 except KeyboardInterrupt:
- 136 raise
- 137 except:
- 138 err = sys.exc_info()
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/nose/case.py in runTest(self=Test(<pgmpy.tests.test_inference.test_ExactInfer...thod=test_query_multiple_variable_with_evidence>), result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
- 147 """
- 148 test = self.test
- 149 plug_test = self.config.plugins.prepareTestCase(self)
- 150 if plug_test is not None:
- 151 test = plug_test
- --> 152 test(result)
- test = <pgmpy.tests.test_inference.test_ExactInference....ethod=test_query_multiple_variable_with_evidence>
- result = <nose.result.TextTestResult run=108 errors=1 failures=0>
- 153
- 154 def shortDescription(self):
- 155 desc = self.plugins.describeTest(self)
- 156 if desc is not None:
- ...........................................................................
- /usr/lib/python3.4/unittest/case.py in __call__(self=<pgmpy.tests.test_inference.test_ExactInference....ethod=test_query_multiple_variable_with_evidence>, *args=(<nose.result.TextTestResult run=108 errors=1 failures=0>,), **kwds={})
- 617 # return this for backwards compatibility
- 618 # even though we no longer us it internally
- 619 return outcome.success
- 620
- 621 def __call__(self, *args, **kwds):
- --> 622 return self.run(*args, **kwds)
- self.run = <bound method TestVariableElimination.run of <pg...thod=test_query_multiple_variable_with_evidence>>
- args = (<nose.result.TextTestResult run=108 errors=1 failures=0>,)
- kwds = {}
- 623
- 624 def debug(self):
- 625 """Run the test without collecting errors in a TestResult"""
- 626 self.setUp()
- ...........................................................................
- /usr/lib/python3.4/unittest/case.py in run(self=<pgmpy.tests.test_inference.test_ExactInference....ethod=test_query_multiple_variable_with_evidence>, result=<nose.result.TextTestResult run=108 errors=1 failures=0>)
- 569 with outcome.testPartExecutor(self):
- 570 self.setUp()
- 571 if outcome.success:
- 572 outcome.expecting_failure = expecting_failure
- 573 with outcome.testPartExecutor(self, isTest=True):
- --> 574 testMethod()
- testMethod = <bound method TestVariableElimination.test_query...thod=test_query_multiple_variable_with_evidence>>
- 575 outcome.expecting_failure = False
- 576 with outcome.testPartExecutor(self):
- 577 self.tearDown()
- 578
- ...........................................................................
- /home/gokul/pgmpy_gk/pgmpy/pgmpy/tests/test_inference/test_ExactInference.py in test_query_multiple_variable_with_evidence(self=<pgmpy.tests.test_inference.test_ExactInference....ethod=test_query_multiple_variable_with_evidence>)
- 54 np.array([0.60, 0.40]))
- 55
- 56 def test_query_multiple_variable_with_evidence(self):
- 57 query_result = self.bayesian_inference.query(variables=['J', 'Q'],
- 58 evidence={'A': 0, 'R': 0,
- ---> 59 'G': 0, 'L': 1})
- 60 np_test.assert_array_almost_equal(query_result['J'].values,
- 61 np.array([0.818182, 0.181818]))
- 62 np_test.assert_array_almost_equal(query_result['Q'].values,
- 63 np.array([0.772727, 0.227273]))
- ...........................................................................
- /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in query(self=<pgmpy.inference.ExactInference.VariableElimination object>, variables=['J', 'Q'], evidence={'A': 0, 'G': 0, 'L': 1, 'R': 0}, elimination_order=None)
- 110 >>> model.fit(values)
- 111 >>> inference = VariableElimination(model)
- 112 >>> phi_query = inference.query(['A', 'B'])
- 113 """
- 114 return self._variable_elimination(variables, 'marginalize',
- --> 115 evidence=evidence, elimination_order=elimination_order)
- evidence = {'A': 0, 'G': 0, 'L': 1, 'R': 0}
- elimination_order = None
- 116
- 117 def max_marginal(self, variables=None, evidence=None, elimination_order=None):
- 118 """
- 119 Computes the max-marginal over the variables given the evidence.
- ...........................................................................
- /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in _variable_elimination(self=<pgmpy.inference.ExactInference.VariableElimination object>, variables=['J', 'Q'], operation='marginalize', evidence={'A': 0, 'G': 0, 'L': 1, 'R': 0}, elimination_order=None)
- 45 for node in self.factors}
- 46
- 47 # Dealing with evidence. Reducing factors over it before VE is run.
- 48
- 49 if evidence: #Implementation of a parallel looping construct
- ---> 50 Parallel(n_jobs=-1, backend="threading") (delayed(self. parallelFor)(evidence_var,working_factors,evidence)for evidence_var in evidence)
- self.parallelFor = <bound method VariableElimination.parallelFor of...rence.ExactInference.VariableElimination object>>
- evidence = {'A': 0, 'G': 0, 'L': 1, 'R': 0}
- 51 # TODO: Modify it to find the optimal elimination order
- 52 if not elimination_order:
- 53 elimination_order = list(set(self.variables) -
- 54 set(variables) -
- ...........................................................................
- /usr/local/lib/python3.4/dist-packages/joblib/parallel.py in __call__(self=Parallel(n_jobs=-1), iterable=<generator object <genexpr>>)
- 655 if pre_dispatch == "all" or n_jobs == 1:
- 656 # The iterable was consumed all at once by the above for loop.
- 657 # No need to wait for async callbacks to trigger to
- 658 # consumption.
- 659 self._iterating = False
- --> 660 self.retrieve()
- self.retrieve = <bound method Parallel.retrieve of Parallel(n_jobs=-1)>
- 661 # Make sure that we get a last message telling us we are done
- 662 elapsed_time = time.time() - self._start_time
- 663 self._print('Done %3i out of %3i | elapsed: %s finished',
- 664 (len(self._output),
- ---------------------------------------------------------------------------
- Sub-process traceback:
- ---------------------------------------------------------------------------
- KeyError Fri Mar 6 23:06:30 2015
- PID: 19709 Python 3.4.0: /usr/bin/python3
- ...........................................................................
- /home/gokul/pgmpy_gk/pgmpy/pgmpy/inference/ExactInference.py in parallelFor(self=<pgmpy.inference.ExactInference.VariableElimination object>, evidence_var='A', working_factors={'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'J': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>])}, evidence={'A': 0, 'G': 0, 'L': 1, 'R': 0})
- 10 def parallelFor(self, evidence_var,working_factors,evidence):
- 11
- 12 for factor in working_factors[evidence_var]:
- 13 factor_reduced = factor.reduce('{evidence_var}_{state}'.format(evidence_var=evidence_var,state=evidence[evidence_var]),inplace=False)
- 14 for var in factor_reduced.scope():
- ---> 15 working_factors[var].remove(factor)
- working_factors = {'A': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'J': set([<pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>, <pgmpy.factors.Factor.Factor object>]), 'Q': set([<pgmpy.factors.Factor.Factor object>])}
- var.remove = undefined
- factor = <pgmpy.factors.Factor.Factor object>
- 16 working_factors[var].add(factor_reduced)
- 17 del working_factors[evidence_var]
- 18
- 19 def _variable_elimination(self, variables, operation, evidence=None, elimination_order=None):
- KeyError: <pgmpy.factors.Factor.Factor object at 0x7f4e4a966400>
- ___________________________________________________________________________
- ----------------------------------------------------------------------
- Ran 253 tests in 1.379s
- FAILED (SKIP=3, errors=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement