-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Added live_traceplot function #1934
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
This is really cool. Will try to take a look soon. |
I wonder if perhaps the API should be: |
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.
This looks super cool, and a really nice use of the iter_sample
. Will take a more substantive look later.
pymc3/sampling.py
Outdated
@@ -16,7 +16,7 @@ | |||
import sys | |||
sys.setrecursionlimit(10000) | |||
|
|||
__all__ = ['sample', 'iter_sample', 'sample_ppc', 'init_nuts'] | |||
__all__ = ['assign_step_methods', 'sample', 'iter_sample', 'sample_ppc', 'init_nuts'] |
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.
intentional?
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.
Yes because iter_sample needs a step function, so if you don't have one already...
pymc3/plots/traceplot.py
Outdated
varnames = get_default_varnames(trace, plot_transformed) | ||
x0 = skip_first | ||
elif (it - skip_first) % refresh_every == 0: | ||
for i, v in enumerate(varnames): |
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.
I haven't looked closely, but do you think it is possible for this code to be factored out and shared with the base traceplot
code?
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, it's a first shot.
Yes, that could be an option, I wasn't sure. |
I get a
I agree with @twiecki that this should be a flag in |
Maybe this is also a good time to mention that |
@aseyboldt I hadn't realized that. Any ideas on how this could be improved? |
@fonnesbeck Sorry I merged a bit quickly, I'll fix and update with the feedback I get. |
@fonnesbeck I checked with Python2.7 and Python3.5, no error on my side. Has anyone else run the notebook? |
I get the same error TypeError. |
It works with this change: diff --git a/pymc3/plots/utils.py b/pymc3/plots/utils.py
index b4ff6f5d..15694817 100644
--- a/pymc3/plots/utils.py
+++ b/pymc3/plots/utils.py
@@ -99,6 +99,6 @@ def fast_kde(x):
norm_factor = n * dx * (2 * np.pi * std_x ** 2 * scotts_factor ** 2) ** 0.5
- grid /= norm_factor
+ grid = grid / norm_factor
return grid, xmin, xmax |
Yes I get the error when upgrading Numpy from 1.11.3 to 1.12.1. |
@davidbrochart You get the error with the fix @aseyboldt posted (which should already be on master, I think @aloctavodia did that)? |
@twiecki No, with @aseyboldt 's fix there is no error any more. |
Are you not on pymc3 master? |
Yes I am now, it works fine. |
I changed the API to what @twiecki suggested, and took into account @ColCarroll 's suggestion on sharing the |
How does this work with a large model? It might be worth allowing a list of the subset of parameters to monitor. |
You can still pass a |
pymc3/plots/traceplot.py
Outdated
@@ -7,7 +7,7 @@ | |||
|
|||
def traceplot(trace, varnames=None, transform=identity_transform, figsize=None, lines=None, | |||
combined=False, plot_transformed=False, grid=False, alpha=0.35, priors=None, | |||
prior_alpha=1, prior_style='--', ax=None): | |||
prior_alpha=1, prior_style='--', ax=None, live_plot=False, skip_first=0, refresh_every=100, roll_over=1000): |
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.
better formatting (new-lines so we don't exceed 80 chars).
LGTM. Seems like you need to rebase. |
* Expand sampler-stats.ipynb example include model diagnose from case study example in Stan http://mc-stan.org/documentation/case-studies/divergences_and_bias.html * Sampler Diagnose for NUTS * descriptive annotation and axis labels * Fix typos * PEP8 styling * minor updates 1, add example to examples.rst 2, original content in Markdown code block
…s/data/__init__.py
* fix some svgd problems * switch -> ifelse * except in record
* add docs * delete redundant code * add usage example * remove unused import
* use only free RVs from trace * use memoize in Histogram.histogram_logp * Change tests for histogram
…pymc3 into live_sample_plots
Not sure what I did here! Let me know if that's okay. |
@davidbrochart Seems like something went wrong, maybe this is helpful: https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request |
Oh actually this seems fine, my bad. |
This is awesome, thanks! |
This allows to have live trace plots in the notebook, which can be useful when you want to see what is going on as you run the simulation.