Skip to content

refactor kde-related functions and small fixes #2191

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

Merged
merged 2 commits into from
May 18, 2017

Conversation

aloctavodia
Copy link
Member

  • Functions inside kdeplot.py were not used. I remove both of them and create a new kdeplot function. Which is used by energyplot and by plotposterior. Besides, this new function can be used to plot any 1D numpy array. Usually I do this with kdeplot from seaborn, but is annoying (and some times confusing to others) that seaborn do not respect boundaries while PyMC3 does.
  • move fast_kde from utils.py to kdeplot.py.
  • remove unused kde2plot_op function inside artistics.
  • fix bug in plotposterior kde plot was not working because figsize was incorrectly passed to ax.plot()
  • According to the docstring of energyplot the default value of alpha=0.35, but it was actually alpha=0.5 (changed to 0.35)
  • replace dictionary inside energyplot by list of tuples in order to guarantee the same order of the plotted data.

@@ -157,3 +137,5 @@ def set_key_if_doesnt_exist(d, key, value):
display_ref_val(ref_val)
if rope is not None:
display_rope(rope)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray extra-line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will fix it.

@twiecki
Copy link
Member

twiecki commented May 17, 2017

This looks great, thanks @aloctavodia!

ax.fill_between(x, density, alpha=alpha)

for label, value in series:
kdeplot(value, label=label, alpha=alpha, shade=True, ax=ax,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to propagate the return values?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. Not sure if I am really understanding you. I think this is what we always do, isn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, sorry, this is fine (ax and fig get updated in place here)

@ColCarroll
Copy link
Member

this is awesome. looks good to merge from me, but I can wait if you want to tidy the formatting first?

Copy link
Contributor

@springcoil springcoil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@springcoil
Copy link
Contributor

I think all the cosmetic changes are made and this is ready to merge.

@twiecki twiecki merged commit 2511a58 into pymc-devs:master May 18, 2017
@hvasbath
Copy link
Contributor

NOOOOO! You removed the kde2plot, I was using it :( ....

@twiecki
Copy link
Member

twiecki commented May 28, 2017

@hvasbath what for?

@twiecki
Copy link
Member

twiecki commented May 28, 2017

You can just copy&paste it to your own code, but it wasn't used by pymc3.

@hvasbath
Copy link
Contributor

Yes I will do that. I produce plots of trade-offs between variables like this:

distribution

@fonnesbeck
Copy link
Member

That's a handsome plot.

@aloctavodia
Copy link
Member Author

@hvasbath do you have plans to add that type of plot to PyMC3? I think it will be a very nice addition. I just hit on this the other day, that maybe useful to check.

@aloctavodia aloctavodia deleted the plotkde branch July 6, 2017 06:00
@hvasbath
Copy link
Contributor

hvasbath commented Jul 6, 2017

If you think it will be useful I can edit my function a little and send a PR. There is absolutely no need to add another dependency for a simple thing like this. If you want to have some covariance ellipses included on top of the true data, we can also include that ...

@aloctavodia
Copy link
Member Author

@hvasbath I think it could be useful.

Sorry I did not explain well myself I was not suggesting adding a dependency (I agree it is not necessary) I just shared the link for reference, just to see what others are doing. Your plot is very nice as is.

@junpenglao
Copy link
Member

Thanks for the link @aloctavodia - It looks more practical to displaying lots of parameters, as the pairplot (I use the one in seaborn) can be incredibly slow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants