jmschrei / pomegranate

Fast, flexible and easy to use probabilistic modelling in Python.
http://pomegranate.readthedocs.org/en/latest/
MIT License
3.29k stars 591 forks source link

[BUG] MLE prediction assignment in Bayesian Network is not consistent? #972

Closed noclew closed 1 year ago

noclew commented 2 years ago

Hello, I got some questions here. First of all, thank you for sharing your awesome work! I am playing around with awesome pomegranate and found MLE estimates of BN are somewhat confusing.

Here I attach my graph as JSON (file extension is txt because JSON was not allowed to attach) graph_data.txt

I want to predict the 8th and 9th variables as below: (Variables are 0 to 10 from left to right)

query = [0, 3, 1, 2, 1, 5, 5, None, None, None, 0]
model.predit([query]))
>> [array([0, 3, 1, 2.0, 1.0, 5.0, 5.0, 1.0, -1.0, -1.0, 0], dtype=object)]

The parent of variables "8" and "9" is "7", and the prediction assigned 1, -1, -1 to the variables "7", "8", "9", respectively. However, if we look at the actual conditional probabilities, P("8" = -1 | "7" = 1) = 0 and P("9" = -1 | "7" = 1) = 0, so this value assignment is not consistent with each other in the same event. If I make a query for multiple missing variables, Does predict function of BN assign the value of each variable based on its marginal probability? Because the joining assignment above cannot happen in the model, I wonder how I should interpret it.

Thanks!

jmschrei commented 1 year ago

Thank you for opening an issue. pomegranate has recently been rewritten from the ground up to use PyTorch instead of Cython (v1.0.0), and so all issues are being closed as they are likely out of date. Please re-open or start a new issue if a related issue is still present in the new codebase.