-
Notifications
You must be signed in to change notification settings - Fork 246
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
Higher level interface for predictions and arviz integration #349
Comments
Could you point to the arviz code that needs access to args / kwargs to run it? I wonder if there is a way to include it in the wrapper for arviz rather than storing it in MCMC.
Could you clarify why we need this? This would have been observed by some observed site like
These should be straightforward to add, once we clarify the issues above. I think predictive can simply be extended because when |
We need arg, kwargs to compute log_likelihood at observe site. The PR
above does not compute log_lik so currently, arviz does not need to access
args, kwargs. Otherwise, numpyro users will need to compute obs_data,
log_likehood themselves and provide them to arviz through from_numpyro
method. That’s fine but redundant to me.
About using sample sites to store transformed values, it is doable if we
relax sample_shape, random_state from fn call (at sample site). Currently
I guess we can do it with: sample(‘return’, lambda sample_shape,
random_state: forecasted_values). Are you suggesting to follow this line? A
concrete example is to get log(y) where y is the returned value from
model(). Another example is to assume that model return loc, scale, we want
to get a sample from Normal(loc, scale) distribution. The generated
quantities from Stan are best to illustrate what I need: get some inferred
values (either stochastic or not) from posterior samples.
…On Tue, Sep 24, 2019 at 7:55 PM Neeraj Pradhan ***@***.***> wrote:
The reason is given a mcmc instance, we do not store args, kwargs, so even
that we can access to model, we still unable to run it from arviz.
Could you point to the arviz code that needs access to args / kwargs to
run it? I wonder if there is a way to include it in the wrapper for arviz
rather than storing it in MCMC.
having _RETURN node in trace as in Pyro and using predictive util to get
values of this node
Could you clarify why we need this? This would have been observed by some
observed site like pyro.sample('obs', .., obs=y). Is it not possible to
extract this from the trace instead? For instance, your forecasting model
above is doing something on top of the model over which we run inference. A
concrete example will help.
make prior_predictive, log_like_predictive utilities.
These should be straightforward to add, once we clarify the issues above.
I think predictive can simply be extended because when posterior_samples
= {}, we will not be conditioning any latent sites and be effectively
sampling from the prior predictive.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#349?email_source=notifications&email_token=ABEEKVTB3CQGG2466OJJLALQLKSIXA5CNFSM4I2C5EQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7QER4A#issuecomment-534792432>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABEEKVW2MUTQEGSHFNHROYLQLKSIXANCNFSM4I2C5EQQ>
.
|
I think we should provide those utility functions, but I'm trying to understand the constraints here. Based on what you say, we could provide a
Can we use something like |
I guess I have given a bad explanation.
For both ways, having
My proposal is to store
Thanks, I didn't know that we can use Delta distribution for this purpose! :D That would be more than enough! ( |
Sure, that sounds reasonable. I suppose we can store the args, kwargs in MCMC and provide a Hmm.. |
Sorry, my bad. I should have distinguished In addition, now I think that having |
I don't think there should be any significant slowdown since the delta won't add anything to the PE term, but adding the same obs keyword isn't a very elegant solution. Do you expect the users to write this forecast function? |
I don't mean the slowdown is caused by using Delta distribution. I mean the slowdown is caused by calculating the extra terms (e.g. log(y)) which does not contribute to joint density computation. But if those extra calculations go inside
I am not sure for other users, but it is enough for my purpose. For example, in the ts forecasting tutorial, I did use the low-level handlers |
Are there any remaining todos on this one? |
Yeah, I need to verify that we fully support arviz. I will make a notebook for verification tomorrow. |
ArviZ integration
In arviz-devs/arviz#811, I already made an attempt for this integration. As demonstrated in InferenceData introduction, there are several groups of an inference data (prior/posterior/predictive/log_lik/inferece_stats/observed_data/...). Currently, users can do something like NumPyro section in ArviZ cookbook. The
az.from_numpyro
requires 3 argsposterior
(which ismcmc
),prior
(i.e. prior_predictive),posterior_predictive
. Currently, we lack a handy utility for prior predictive.Internally, we lack
observed_data
andlog_lik
groups. The reason is given amcmc
instance, we do not storeargs
,kwargs
, so even that we can access to model, we still unable to run it fromarviz
.observed_data
is required for ppcplot or plot_loo_pit.log_lik
is useful for many stuffs, including some bayesian criterions.Solutions:
run
method to MCMC state.SVI
I think that current
predictive
utility is enough to get samples fromguide
(similar to the sample_posterior method in autoguide).What predictive likes in other frameworks
Stan has generated quantities block, which is used to
PyMC3 has deterministic nodes to keep track of transformed variables and posterior_predictive to get values at observed nodes.
Typically, for prediction/forecasting, I imagine we will do something like
I think we can do all the above tasks by either
predictive
util to get values of this nodeinclude_returned_values
in predictive (or having another predictive utility for this purpose) which will runcondition(model, preditive_sites + posterior_sites)(*args, **kwargs)
to get those returned values. I prefer this. The minor drawback of this way is we will run the model 2 times: one to get predictive samples, another one to get returned values.The text was updated successfully, but these errors were encountered: