Skip to content
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

Automatically handle warmup draws and sampling metadata from_pymc3 #1146

Closed
michaelosthege opened this issue Apr 11, 2020 · 0 comments · Fixed by #1171
Closed

Automatically handle warmup draws and sampling metadata from_pymc3 #1146

michaelosthege opened this issue Apr 11, 2020 · 0 comments · Fixed by #1171

Comments

@michaelosthege
Copy link
Contributor

Tell us about it

The trace.report in PyMC3 now has attributes n_tune, n_draws and t_sampling (see pymc-devs/pymc#3827).

I have this snippet to store those metadata with the trace:

idat = arviz.from_pymc3(trace)
if hasattr(trace.report, 'n_tune'):
        idat.posterior.attrs['n_tune'] = trace.report.n_tune
        idat.posterior.attrs['n_draws'] = trace.report.n_draws
        idat.posterior.attrs['t_sampling'] = trace.report.t_sampling

Using n_draws, one can now slice a trace that contains warmup iterations:

trace_warmup = trace[:-trace.report.n_draws]   # <-- may result in len(trace_warmup) == 0
trace_posterior = trace[-trace.report.n_draws:]

Thoughts on implementation

I suppose both snippets should find their place in the PyMC3Converter, but I'm not sure how saving the warmup should be done.

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 a pull request may close this issue.

1 participant