Closed 1pakch closed 6 years ago
Howdy
Thanks for pointing out the issue. After some initial digging, it looks like the issue is because I use loopy belief propogation on a factor graph, which is a fast and sometimes-exact approximate algorithm. If you have a tree-like network at the unobserved variables, or you're only doing a forward pass of inference, this algorithm will be exact. Otherwise, it is not guaranteed to be. It looks like in this particular case it converges to being more confident that the sprinkler is the culprit.
If you're looking for results more closely matching the exact algorithm on simple Bayesian networks, you can set max_iterations=1
in the predict_proba
method and the result you get is a 33.2% chance that it rained.
The reason that I use the approximate algorithm versus the exact algorithm is two fold. The first is that it's much easier to implement the approximate algorithm. The second is that it scales well on larger Bayesian networks, and is even typically much faster on smaller ones, while still preserving the argmax over the keys.
Let me know if you have any other questions!
Thanks a lot for the answer! I might create a PR with updated docs in the unlikely case I will find a bit of free time:)
There is another problem which occurs when I try to use pomegranate
for simple genetics. I submitted it as a separate issue #446.
I implemented the Bayesian network example presented on Wikipedia for Bayesian networks witn pomegranate 0.8.1. Inference using
predict_proba
fails to produce the right answer. The state probabilities seem to be correct. Am I missing something?