Skip to content

Allow to save/load model? #150

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

Closed
ItsJamesMurray opened this issue Feb 11, 2023 · 4 comments
Closed

Allow to save/load model? #150

ItsJamesMurray opened this issue Feb 11, 2023 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ItsJamesMurray
Copy link

Is there a plan to add the option to save or load the model? In lifetimes, there is an option to do so.

@zwelitunyiswa
Copy link

You could just save the inference data with Arviz:

https://python.arviz.org/en/0.14.0/api/generated/arviz.to_netcdf.html

The inference data is just the result of your .fit method (or the result after you run a posterior predictive as well).

@ricardoV94 ricardoV94 added enhancement New feature or request help wanted Extra attention is needed labels Feb 15, 2023
@ricardoV94
Copy link
Contributor

We may need a method to load fits back into the specific models created here, so I'll add this as a feature request. Thanks for asking

@twiecki
Copy link
Contributor

twiecki commented Feb 15, 2023

We could inherit from ModelBuilder: pymc-devs/pymc-extras#104

@ColtAllen
Copy link
Collaborator

In my fork of lifetimes I added support for saving/loading the model InferenceData object as a JSON:

https://github.com/ColtAllen/btyd/blob/main/btyd/models/__init__.py#L157

The model name gets appended to posterior variable names when the model is fit. load_json() checks the variable names in the JSON to ensure it's being loaded into the correct model type.

However, ModelBuilder may offer more functionality. Users will probably want options for things like including the observation data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants