BAyesian Model-Building Interface (Bambi) in Python#

PyPI version Tests Coverage Black

Bambi is a high-level Bayesian model-building interface written in Python. It works with the probabilistic programming frameworks PyMC and is designed to make it extremely easy to fit Bayesian mixed-effects models common in biology, social sciences and other disciplines.

Dependencies#

Bambi is tested on Python 3.8+ and depends on ArviZ, formulae, NumPy, pandas and PyMC (see requirements.txt for version information).

Installation#

Bambi is available from the Python Package Index at https://pypi.org/project/bambi/, alternatively it can be installed using Conda.

PyPI#

The latest release of Bambi can be installed using pip:

pip install bambi

Alternatively, if you want the bleeding edge version of the package, you can install from GitHub:

pip install git+https://github.com/bambinos/bambi.git

Conda#

If you use Conda, you can also install the latest release of Bambi with the following command:

conda install -c conda-forge bambi

Usage#

A simple fixed effects model is shown in the example below.

import arviz as az
import bambi as bmb
import pandas as pd

# Read in a tab-delimited file containing our data
data = pd.read_table('my_data.txt', sep='\t')

# Initialize the fixed effects only model
model = bmb.Model('DV ~ IV1 + IV2', data)

# Fit the model using 1000 on each of 4 chains
results = model.fit(draws=1000, chains=4)

# Use ArviZ to plot the results
az.plot_trace(results)

# Key summary and diagnostic info on the model parameters
az.summary(results)

For a more in-depth introduction to Bambi see our Quickstart or our set of example notebooks.

Citation#

If you use Bambi and want to cite it please use

@article{Capretto2022,
        title={Bambi: A Simple Interface for Fitting Bayesian Linear Models in Python},
        volume={103},
        url={https://www.jstatsoft.org/index.php/jss/article/view/v103i15},
        doi={10.18637/jss.v103.i15},
        number={15},
        journal={Journal of Statistical Software},
        author={Capretto, Tomás and Piho, Camen and Kumar, Ravin and Westfall, Jacob and Yarkoni, Tal and Martin, Osvaldo A},
        year={2022},
        pages={1–29}
        }

Contributing#

We welcome contributions from interested individuals or groups! For information about contributing to Bambi, check out our instructions, policies, and guidelines here.

Contributors#

See the GitHub contributor page.

Contents#

Indices#