-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Mark pm.Data
nodes in graphviz graphs.
#3491
Conversation
Need to revise a test to make this OK. |
pymc3/model_graph.py
Outdated
@@ -108,7 +104,15 @@ def _make_node(self, var_name, graph): | |||
if hasattr(v, 'distribution'): | |||
distribution = v.distribution.__class__.__name__ | |||
else: | |||
distribution = 'Deterministic' | |||
is_data = False # type: bool |
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.
From looking at the source code for the Data
class, you only need to test if v
is an instance of SharedVariable
. A deterministic will never be an instance of SharedVariable
because of the call to copy
which at most will return a view of a shared variable, which is not an instance of SharedVariable
itself.
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.
@lucianopaz
Thanks! Fixed that and the test that was failing. If this is OK with people, we can merge it (although I will clean up the history first).
I would like to figure out how to put data that are observations below the observed node, instead of above, but I don't sufficiently understand what can be in the observed
property of a random variable. Do I need to check to see if it's a SharedVariable
, and then see if it has a name
property? Are those sufficient and necessary conditions?
Thanks for including samples -- do the |
I didn't look into this that carefully. It looks like the observation ones do, at least to the extent of being placed in the right plates (all those observations in my model have the same shape -- they are vectors 1043 long). |
1 similar comment
I didn't look into this that carefully. It looks like the observation ones do, at least to the extent of being placed in the right plates (all those observations in my model have the same shape -- they are vectors 1043 long). |
Just pushed a cleaned-up version with all the various blind-alleys, etc. removed from the history. If people are happy with it after that, let's merge. I don't know if it needs to be written up in the release notes, since it's a pretty straightforward cosmetic enhancement. |
Sorry to nag, but -- ok to merge? |
pm.Data
nodes in graphviz graphs.pm.Data
nodes in graphviz graphs.
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.
Looks good to merge if you can confirm that not every shape is a rectangle in the resulting graph!
pymc3/model_graph.py
Outdated
else: | ||
distribution = 'Deterministic' | ||
attrs['shape'] = 'box' | ||
attrs['shape'] = 'box' |
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.
is this making every shape a box?
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.
Probably yes. Looks like I have an indentation error there. Quick question: when I fix this, should I use a different shape for Data
than Deterministic
? E.g., make Data
be a roundtangle?
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.
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.
Tests should be fixed now. If they go, I propose to squash again, test again, and merge.
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.
What about Potential
nodes? I think they were triangles back in PyMC2.
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.
What about
Potential
nodes? I think they were triangles back in PyMC2.
I don't mind having a whack at that, but I'd prefer to have it be a new issue and a new PR. If you would post a new issue about this, with a small model that has a potential in it, I'll have a look. But now I am going to squash this commit, and as long as that doesn't break anything, merge it and close this out.
[I don't mean to seem abrupt, but it is a lot of mental work -- at least for me -- to keep multiple topic branches open.]
f31d7f4
to
5455770
Compare
Oy, sorry to keep tossing things your way @rpgoldman, but can you also add a line to RELEASE_NOTES.md? I think @twiecki is also trying to get 3.7 released, so you might even start a new section for pymc 3.8, and we can merge this right after the release. |
@ColCarroll @fonnesbeck Since the merge is going to be delayed, would you like to send me a tiny model with a |
@fonnesbeck Triangles for potentials look pretty ugly IMO: |
@fonnesbeck How about this instead? |
Mark Data nodes in graph: previously these were incorrectly marked as `Deterministic`. Mark Potential nodes in graph. Also distinguish between Deterministic, Data, and Potential nodes by node shape. Put observations below observed nodes: Now that there are `Data` objects that are graphable, they need to be placed correctly with respect to other nodes: if they are inputs they should be above, and if they are observations, they should be below.
If this passes tests once again, may I pretty-please merge it? |
Sorry for the slow reply. I think these look fantastic. Merging. |
No description provided.