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

Use of pymc3 _model pointer will cause future problems #939

Closed
rpgoldman opened this issue Dec 4, 2019 · 0 comments
Closed

Use of pymc3 _model pointer will cause future problems #939

rpgoldman opened this issue Dec 4, 2019 · 0 comments

Comments

@rpgoldman
Copy link
Contributor

Describe the bug
In data/io_pymc3/ the PyMC3Converter finds the PyMC3 model -- which it needs to interpret the trace, through a pointer hidden in the pm.MultiTrace object.

This use will not be compatible with out-of-sample prediction, which in PyMC3 requires using a thinned trace in a different model (in general, one with different predictors and different dimensions).

See

# This next line is brittle and may not work forever, but is a secret
# way to access the model from the trace.
if trace is not None:
self.model = self.trace._straces[0].model # pylint: disable=protected-access
self.nchains = trace.nchains if hasattr(trace, "nchains") else 1
self.ndraws = len(trace)
else:
self.model = None
self.nchains = self.ndraws = 0
# this permits us to get the model from command-line argument or from with model:
try:
self.model = self.pymc3.modelcontext(model or self.model)
except TypeError:
self.model = None

We have already added an explicit model argument to the translator. The next step would be to deprecate using the existing back door and move towards making the PyMC3 Model object a mandatory argument.

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

No branches or pull requests

2 participants