Skip to content

How to properly calculate inference for Bayesian net? #1746

Answered by ankurankan
ferencbartok asked this question in Q&A
Discussion options

You must be logged in to vote

@ferencbartok I am not exactly sure what you are trying to compute in the example above. Could you elaborate a bit please? If you are looking to compute the (posterior) marginal distributions over all variables given some evidence you could do something like:

In [13]: from pgmpy.utils import get_example_model
In [14]: model = get_example_model('alarm')
In [15]: from pgmpy.inference import VariableElimination
In [16]: infer = VariableElimination(model)
In [18]: observation = {'CVP': 'LOW', 'PAP': 'HIGH'}
In [19]: for node in model.nodes():
    ...:     if node not in observation:
    ...:         infer.query([node], evidence=observation)

By default pgmpy tries to compute the joint disribut…

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
9 replies
@ferencbartok
Comment options

@ferencbartok
Comment options

@ankurankan
Comment options

@ferencbartok
Comment options

@ankurankan
Comment options

Answer selected by ferencbartok
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants