Loading PPC data into arviz in pymc3
See original GitHub issueCurrently, the easiest way to get data from pymc3 into arviz is via pm.sample(return_inferencedata=True)
, which gives back an arviz InferenceData object. However, pm.sample_posterior_predictive()
only supports dictionary returns.
It’s unclear what the right approach is, as at this point the InferenceData object is already created. I guess we either need an easy, dimension-aware way to add the PPC data later or create a new object with it.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Prior and Posterior Predictive Checks — PyMC3 3.11.5 ...
Posterior predictive checks (PPCs) are a great way to validate a model. The idea is to generate data from the model using parameters...
Read more >Hands On Bayesian Statistics with Python, PyMC3 & ArviZ
Appreciate The Gurus team for scraping the data set. from scipy import stats import arviz as az import numpy as np import matplotlib.pyplot...
Read more >arviz.plot_ppc: "posterior predictive mean" - Stack Overflow
As you can see both plots show the "posterior predictive mean score", ... Both figures were made using the same data: ... pymc3...
Read more >Introduction to Computational Statistics with PyMC3
%matplotlib inline import arviz as az import numpy as np import warnings ... of predicted y for each original x in our data...
Read more >| notebook.community
%matplotlib inline import sklearn import scipy.stats as stats import ... packaging in /usr/local/lib/python3.6/dist-packages (from arviz>=0.4.1->pymc3==3.8) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks, the az.concat idea is working, and I’m testing out the PR branch of pymc3 that fixes the keep_size issue. So I think I’m now on track again 😃.
To add posterior predictive samples to an inference data object with pymc3, I think the best approach is:
There is also issue #1239 to make this last line less convoluted.
As Robert pointed out, to add predictions (out of sample posterior predictive samples) the way to go should be
from_pymc3_predictions
as this will add the samples returned bysample_posterior_predictive
topredictions
groups as well as the data used to generate them toconstant_data_predictions
(assuming you are usingpm.Data
container).I commented in the issue you linked as there seems to be a bug with
keep_size
is a dataset is passed so most of this won’t work for now 😕