D-K-E / graphical-models

Probabilistic Graphical Models from Scratch with support for LWF Chain Graphs
GNU General Public License v3.0
4 stars 2 forks source link

I fixed the usage examples so they run with the new API #15

Closed murphyk closed 9 months ago

murphyk commented 9 months ago

The usage examples at https://d-k-e.github.io/graphical-models/html/d3/db0/md_graphical-models_docs_mdpages_usage.html do not run with the current code. I fixed the issues and put the new version here: https://github.com/probml/pyprobml/blob/master/notebooks/misc/pygmodels_doc.ipynb

I also added a visualization of the chain graph here: https://gist.github.com/murphyk/e157531793f87f3d1eb9542234e6bc7d However I suggest you rename the variables so they match the notation in the book...

D-K-E commented 9 months ago

Wow! The man himself. Thank you for your contribution, I'll add the fix right away. For the variables, you mean instead of naming them as A, B, C, ..., they should be named as Smoking, Tuberculosis, ..., right ?

murphyk commented 9 months ago

Yes, for the variable names in the chain graph example, I mean: be consistent with the Cowell book. For example, they write p(C,D | B,E) = phi(C,D,B) phi(C,B,E) 1/Z(B,E) but you write p(H,I|B,D) = phi(H,I,B) phi(H,B,D) phi(B,D) where H=Cough, I=Dysponea, B=Bronchitis, D=Either. This is confusing.

D-K-E commented 9 months ago

Okay I see what you mean, I'll fix it right away

D-K-E commented 9 months ago

The latest commit 0a6ec0c in master branch now updates the usage examples section of the docs, related notebooks and aligns the names of variables in LWF-Chain graph example to those of Cowell as shown in here. Thank you again for bringing this up.

The library is still undergoing heavy refactoring, and I plan to break backwards compatibility on a lot of the existing api for the next release. I am particularly unsatisfied about how random variables are handled currently. If you have any recommendations both in terms of features or in terms of api design, usage or others, I'd love to hear it.

murphyk commented 9 months ago

This is now much clearer. I suggest updating https://github.com/D-K-E/graphical-models/tree/master#usage-examples so it points to the new example notebooks, rather than the old page.

(BTW I updated the image at https://gist.github.com/murphyk/e157531793f87f3d1eb9542234e6bc7d, so the single letter variable names match the book, rather than your old code)