You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wonder what is the syntax to query a Bayesian Network's (BN) joint probability with some evidence? The docs seem a little bit too brief and lots of syntaxes are not mentioned.
Based on this infer statement: infer(ExactInference(), bn, [:distance], evidence=Assignment(:carrier_id=>15))
I have tried to omit the query objects (e.g., [:a,:b]) from the infer statement: infer(ExactInference(), bn, evidence=Assignment(:carrier_id=>15))
and BayesNets.jl output compilation errors: MethodError: no method matching infer(::ExactInference, ::DiscreteBayesNet; evidence=Dict{Symbol, Any}(:carrier_id => 15))
I wonder if such feature is implemented or will it be on plan? Really looking forward to your reply! Thank you so much!
The text was updated successfully, but these errors were encountered:
A call to infer produces a joint distribution over all given target variables (which cannot include evidence variables). To get the effect you requested, just expand [:distance] to include all variables in the BN other than carrier_id.
Thank you for the reply. Sorry again, assuming that I have a BN as "year -> distance -> origin_id", and I have observed origin_id=>1, I wonder how can I get the joint distribution for this BN with this evidence?
What I have tried:
result = infer(ExactInference(), bn, [:year,:distance], evidence=Assignment(:origin_id=>1)).potential
result = sum(result, dims=(1, 2))
which means I got the joint distribution of this BN as 1. This sum up to one should not happen because of the evidence. I wonder what did I do wrong? Thank you for help!
The result of infer is going to be a factor table, which will have normalized probability values. Summing over them will always produce 1.
If it isn't displaying properly, please try viewing the factor in IJulia, or maybe printing it out after converting it to a DataFrame. convert(DataFrame, ϕ).
Hello,
I wonder what is the syntax to query a Bayesian Network's (BN) joint probability with some evidence? The docs seem a little bit too brief and lots of syntaxes are not mentioned.
Based on this infer statement:
infer(ExactInference(), bn, [:distance], evidence=Assignment(:carrier_id=>15))
I have tried to omit the query objects (e.g., [:a,:b]) from the infer statement:
infer(ExactInference(), bn, evidence=Assignment(:carrier_id=>15))
and BayesNets.jl output compilation errors:
MethodError: no method matching infer(::ExactInference, ::DiscreteBayesNet; evidence=Dict{Symbol, Any}(:carrier_id => 15))
I wonder if such feature is implemented or will it be on plan? Really looking forward to your reply! Thank you so much!
The text was updated successfully, but these errors were encountered: