Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated graphs may not be DAG #11

Open
vangj opened this issue Feb 28, 2023 · 0 comments
Open

Generated graphs may not be DAG #11

vangj opened this issue Feb 28, 2023 · 0 comments

Comments

@vangj
Copy link
Owner

vangj commented Feb 28, 2023

from pybbn.generator.bbngenerator import generate_multi_bbn, convert_for_exact_inference
from pybbn.sampling.sampling import LogicSampler


bbn = convert_for_exact_inference(*generate_multi_bbn(20, max_iter=5_000))
sampler = LogicSampler(bbn)
print(sampler.nodes)

samples = sampler.get_samples(n_samples=5, seed=37)

print(samples)

Will result in the following.

Traceback (most recent call last):
  File "/Users/super/git/summer-camp/web/pyodide/data/generate.py", line 9, in <module>
    samples = sampler.get_samples(n_samples=5, seed=37)
  File "/opt/anaconda3/lib/python3.9/site-packages/pybbn/sampling/sampling.py", line 138, in get_samples
    val = table.get_value(p, sample=sample)
  File "/opt/anaconda3/lib/python3.9/site-packages/pybbn/sampling/sampling.py", line 65, in get_value
    k = ','.join([f'{i}={sample[i]}' for i in self.parent_ids])
  File "/opt/anaconda3/lib/python3.9/site-packages/pybbn/sampling/sampling.py", line 65, in <listcomp>
    k = ','.join([f'{i}={sample[i]}' for i in self.parent_ids])
KeyError: 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant