-
-
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
[WIP] Adding more detailed info to GraphViz renderings #3956
Conversation
thanks for the contribution! i'll try to take a look at this during the weekend. some brief thoughts in the meantime:
|
Thanks for having a look so quickly already.
I agree. How about: (1) move functionality currently in the various |
That sounds like it would work. That'd be neat to have a nice |
(hopefully the rebase here isn't too messy -- the code looks good and compact enough that it shouldn't be...) |
@Spaak Any time for the rebase so we can merge this in? |
I'm away at the moment but will get to it the week of 10 Aug!
…On Mon, 27 Jul 2020, 11:46 Thomas Wiecki, ***@***.***> wrote:
@Spaak <https://github.com/Spaak> Any time for the rebase so we can merge
this in?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3956 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXG3P2UD4O3Z4DZYFS6RQLR5VEF7ANCNFSM4N4L6N5A>
.
|
Great, thanks for the update!
On Mon, Jul 27, 2020 at 1:02 PM Eelke Spaak <notifications@github.com>
wrote:
… I'm away at the moment but will get to it the week of 10 Aug!
On Mon, 27 Jul 2020, 11:46 Thomas Wiecki, ***@***.***>
wrote:
> @Spaak <https://github.com/Spaak> Any time for the rebase so we can
merge
> this in?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#3956 (comment)>,
or
> unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AAXG3P2UD4O3Z4DZYFS6RQLR5VEF7ANCNFSM4N4L6N5A
>
> .
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3956 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFETGEHKC2K2AA7ICXJ6Q3R5VNCRANCNFSM4N4L6N5A>
.
|
8ac8bc1
to
c6d5cdf
Compare
Codecov Report
@@ Coverage Diff @@
## master #3956 +/- ##
==========================================
- Coverage 86.79% 86.73% -0.07%
==========================================
Files 88 88
Lines 14143 14158 +15
==========================================
+ Hits 12276 12280 +4
- Misses 1867 1878 +11
|
@Spaak You also need to rebase as we fixed some things for CI on master. |
@twiecki I'm still adding some functionality (refactoring the
I rebased my branch onto current master already, and did a force push after that. That should take care it, right? If not, let me know. (I'll rebase again, if needed, after the functionality here is complete and ready for merge.) |
Co-authored-by: Thomas Wiecki <thomas.wiecki@gmail.com>
…rather than full new str repr
…er-facing __str__
I think I might need some input @twiecki @ColCarroll . First of all, as you can see this PR grew substantially and now is much more about streamlining general string representations of variables and distributions. This has two significant advantages:
The changes to achieve the above are all now already in this PR. When the tests started running, I noticed that existing PyMC3 code relies on This PR actually already has a function Apologies for letting this PR get out of hand a bit, I do think it's a potential improvement to the code though; hope you agree ;) |
@twiecki @ColCarroll I'm going to split this up into several PRs that depend on each other (i.e. I'll file PR n after n-1 is merged). It'll probably be 3PRs along the following lines:
Hope that works and will make it a bit easier to review! |
Note: this PR is a work in progress, and some brief feedback would be welcome before I add some more commits to finalize the functionality (if it's desirable at all, of course).
I very much like the GraphViz rendering functionality, but have noticed that complex/bigger models often result in extremely wide graphs with very wide, horizontally elongated, nodes. The first very simple thing that this PR does is it places the distribution a new line in the node text ("MyVar ~ Normal" --> "MyVar\n~\nNormal"), which results in more evenly distributed graphs (nodes considerably less wide).
The second, more elaborate thing, this PR does is it adds a
include_prior_params
option to themodel_to_graphviz
functionality. The idea is that this would enable display of not just e.g. "MyVar ~ Normal", but "MyVar ~ Normal(mu=1, sigma=0)" in the graph nodes. To me at least this would be useful functionality. See this simple rendering:As of now, the functionality supports
Normal
andUniform
, but others are trivial to add (and I'll add before this PR should be merged). But before I do that, I had two questions:I couldn't find any unified mechanism by which
Distribution
subclasses advertise their parameters. Many distributions have a_repr_latex()
method which I had a look at, and saw that each subclass hard-codes its parameters of interest there. I didn't want to introduce a general mechanism by which distributions advertise their parameters (as this seems a somewhat major overhaul), so instead I opted to add adict
toModelGraph
that maps distributions to their parameters of interest. For now I just addedNormal
andUniform
, but if you agree this is the way to go I'll add the rest (just a bit of monkey work--happy to do it but won't if this is inappropriate of course ;) ).I noticed (and am using) the
util.get_variable_name
function, which is somewhat strangely named since it actually returns a variable's value, or a description of that value. I think the general logic of the function is highly relevant to what this PR is trying to do, but it has some LaTeX hardcoded in it (only'\text{%s}'
at the end). Perhaps that's OK to remove?