-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add graphviz model graphs #3049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
for more information. | ||
""" | ||
model = pm.modelcontext(model) | ||
return ModelGraph(model).make_graph() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need newline
pymc3/model_graph.py
Outdated
if parents != upstream: | ||
det_map = {} | ||
for d in deterministics: | ||
d_set = set([j for j in inputs([func], blockers=[d])]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just use a set comprehension: {j for j in inputs([func], blockers=[d])}
This is great! Can we just make this the repr for |
This looks very cool! Have you considered daft? |
This is awesome! Is there still any problem of installation of graphviz on Mac and Windows? Could somebody with a winOS test this? |
|
This is awesome, the radon example is much improved due to this. |
@ColCarroll fair enough on not wanting to have graphviz as a hard dependency. Would be cool, but probably not worth the pain. |
I took a small look at making this the repr, but it looks confusing (ipython/ipython#11202).
Anyways, I think this is ready to merge. |
(merged to avoid conflicts with README.md with a bunch of other PRs coming... feel free to revert if there are more issues!) |
This follows #1683 and #876 to create model representations for graphs. I also reran the multilevel modeling notebook, updating a bit of the code, and adding the graphs for each of the models.
Installation of graphviz is now supported on conda-forge, and is used in
dask
, so it seems like a reasonable choice. I've also isolated the code, so it is easy to remove if it causes headaches.The function takes only one (optional) argument - the model object, which it can graph from the context manager if necessary. It returns a
graphviz.Digraph
, so if someone wanted to customize the object for publication or any other reason, that is surprisingly easy. My favorite part is that the graphs display inline in a notebook.I've included two examples of the graphs from the Radon example, since they look interesting, and show all of the styling I added: