Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numpyro_oop-0.0.1.tar.gz (16.1 kB view hashes)

Uploaded Source

Built Distribution

numpyro_oop-0.0.1-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page