Open rpgoldman opened 5 years ago
As far as I can tell from reading the data, the only thing that will show up in this group is the set of variables in the model that are not contained in the set of default varnames. I don't see how this lets us load predictors. Unless possibly it is intended that we make all of the predictors be
pm.Data
objects.
Yes, the logic behind this is that if there are pm.Data
variables which are not observed variables, they will probably be predictors, so they are automatically loaded into constant_data
group. Therefore, iff you want the predictors to be loaded directly into the InferenceData
object using only from_pymc3
they should all be pm.Data
.
In order to store any set of predictors whether they are pm.Data
or not they would have to be loaded into another InferenceData
object and then concatenate it with the result of from_pymc3
.
Maybe we could add a constant_data
argument in from_pymc3
to directly load a dict of predictors into constant_data
group, as I do not think data like sigma
in the cookbook model is stored in any way by PyMC3. We can use this issue to discuss a better integration of constant_data
with PyMC3.
- I don't believe the
constant_data
are necessarily constant across groups, are they? If one has a regression model, then probes it with prior predictive sampling or posterior predictive sampling, then the value of predictors might be different in theposterior
,prior
, andposterior_predictive
, mightn't they?
They may be different between prior run (prior and prior_predictive) and posterior run (posterior, observed data and posterior predictive) but then you would probably be working with different models given that the predictors are different, so it may be better to store them in different InferenceData
s.
- I don't believe the
constant_data
are necessarily constant across groups, are they? If one has a regression model, then probes it with prior predictive sampling or posterior predictive sampling, then the value of predictors might be different in theposterior
,prior
, andposterior_predictive
, mightn't they?They may be different between prior run (prior and prior_predictive) and posterior run (posterior, observed data and posterior predictive) but then you would probably be working with different models given that the predictors are different, so it may be better to store them in different
InferenceData
s.
Actually, I think that PyMC3's pm.Data
objects are specifically designed to enable programmers to change the predictors and re-run the model.
If we are doing posterior predictive sampling with different predictors to, for example, generalize to conditions we have not seen, we cannot simply make a new, different model, or a new InferenceData
(since the structure of the InferenceData
object depends heavily on the structure of the posterior trace passed to from_pymc3()
@michaelosthege I think we can close this now that v4 will allow constant pm.Data so that they are added in InferenceData but don't represent a performance penalty due to being shared variables.
@michaelosthege I think we can close this now that v4 will allow constant pm.Data so that they are added in InferenceData but don't represent a performance penalty due to being shared variables.
Was there a PR about this already?? I opened https://github.com/pymc-devs/pymc/issues/5105 , but I don't recall that it's been worked on yet.
Was there a PR about this already??
I don't know, I just figured there would be an open issue/PR that would be better placed to track this than this one
How to plot a Posterior Predictive Check Plot using Pymc&Arviz? I can't go through with this new version.please help!
pymc==5.16.2 arviz==0.19.0
with model:
ppc = pm.sample_posterior_predictive(trace)
az.plot_ppc(az.from_pymc3(trace=trace, posterior_predictive=ppc, model=model))
AttributeError: module 'arviz' has no attribute 'from_pymc3'
import arviz as az print(hasattr(az, 'from_pymc3')) print(hasattr(az, 'from_pymc')) False False
@yanshiwei2020 please refer to the documentation on core features: https://www.pymc.io/projects/docs/en/stable/learn/core_notebooks/index.html
also, your question has nothing to do with this issue
Short Description
The latest version of arviz has
constant_data
in theInferenceData
object. I assume that this is intended to support plotting regressions by allowing us to add predictors toInferenceData
.As far as I can tell from reading the data, the only thing that will show up in this group is the set of variables in the model that are not contained in the set of default varnames. I don't see how this lets us load predictors. Unless possibly it is intended that we make all of the predictors be
pm.Data
objects.Also, the user cannot set
constant_data
when building anInferenceData
object from a prior predictive model, which means, I believe, that we won't be able to use arviz to plot when we do prior predictive samples with known predictors to examine our prior regression model.I can think of some possible improvements:
We could enable the insertion of constant data for prior predictive and posterior predictive samples alone (i.e., without a posterior trace), by using pymc3's
modelcontext()
. This would enable someone to write code like:This might, potentially, allow programmers to put
coords
anddims
into thepymc3.Model
object.I don't believe the
constant_data
are necessarily constant across groups, are they? If one has a regression model, then probes it with prior predictive sampling or posterior predictive sampling, then the value of predictors might be different in theposterior
,prior
, andposterior_predictive
, mightn't they? One could, of course, make differentInferenceData
objects for these cases, but then one runs into the problem that the only way to getconstant_data
populated is by providing aMultiTrace
from which arviz can extract theModel
object.Code Example or link
Please provide a minimal, self-contained, and reproducible example demonstrating what you're trying to do. Ideally it will be a code snippet, link to a notebook, or link to code that can be run on another user's computer.
Also include the ArviZ version and version of any other relevant packages.
Relevant documentation or public examples
Please provide documentation, public examples, or any additional information which may be relevant to your question