MaxHalford / sorobn

🧮 Bayesian networks in Python
https://sorobn.streamlit.app
MIT License
234 stars 34 forks source link

Differences in posterior probabilities for `Asia` example network #17

Closed jaeckdaniel closed 3 years ago

jaeckdaniel commented 3 years ago

Hi Max,

thanks so much for setting up such a great library with a very clean and concise API!

I have a quick question regarding the posterior probabilities of the Asia network example:

If I select Dispnea as query variable and no event variables in your demo app, I get the following posterior probabilities:

Dispnea P(Dispnea)
0       0.5640
1       0.4360

These are also the values that you see in other sources using the Asia example (e.g., Bayes Server or Netica)

If I run the following code in Python (3.9.2), I get the following posterior probabilities for the Dispnea node:

>>> import hedgehog as hh
>>> bn = hh.examples.asia()
>>> bn.query("Dispnea", event={})

Dispnea
False    0.602547
True     0.397453
Name: P(Dispnea), dtype: float64

Do you know what is causing these differences, or am I using the API incorrectly?

Thanks a lot! Daniel

MaxHalford commented 3 years ago

Good catch! I had introduced a typo when tidying the probability tables. It's fixed now. Cheers!

jaeckdaniel commented 3 years ago

Thanks so much for the quick fix, @MaxHalford . Cheers!