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
- CI test setup
- 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.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | acc15c687b4520428c16a1d0c9b34a962696dcbe9a48d514612dbc32b8a7fb74 |
|
MD5 | 7a6a88b2d319daf5848b253510f766af |
|
BLAKE2b-256 | f31cd0540e771ea9a5c5e510fe2567b61de8fcaf3cb7c84723171fa450a4b7be |