A convenient object-oriented wrapper for working with numpyro models.
Project description
An object-oriented interface to numpyro
This package provides a wrapper for working with numpyro models. It aims to remain model-agnostic, but package up a lot of the model fitting code to reduce repetition.
It is intended to make life a bit easier for people who are already familiar with Numpyro and Bayesian modelling. It is not intended to fulfil the same high-level wrapper role as packages such as brms. The user is still required to write the model.
Getting started
pip install numpyro-oop
The basic idea is that the user defines a new class that inherits from BaseNumpyroModel
,
and defines (minimally) the model to be fit by overwriting the model
method:
from numpyro_oop import BaseNumpyroModel
class DemoModel(BaseNumpyroModel):
def model(self, data=None):
...
m1 = DemoModel(data=df, seed=42)
Then all other sampling and prediction steps are handled by numpyro-oop
, or related libraries (e.g. arviz
):
m1.sample() # sample from the model
preds = m1.predict() # generate model predictions for the dataset given at initialization, or pass a new dataset
m1.generate_arviz_data() # generate an Arviz InferenceData object stored in self.arviz_data
A more complete demo can be found in /scripts/demo_1.ipynb
.
Roadmap after initial release
- include doctest, improved examples
- demo and tests for multiple group variables
- export docs to some static page (readthedocs or similar); detail info on class methods and attributes
- Contributor guidelines
- Fix type hints via linter checks
Development notes
- Update dependencies with
make update-deps
- Update and (re)install the environment with
make update-and-install
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for numpyro_oop-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f350a524da9f71f61d899c2d223c42c348c42b28e65344a96b5c0ea9791c126 |
|
MD5 | 8bc9cdfc115e72e281a9e6095e1716ad |
|
BLAKE2b-256 | aa925ad9c90bd8b006f420aad9f5f2ef176c899ba279091383ce43b19062a796 |