Skip to main content

A Python package for Bayesian Inference modeling and diagnostics.

Project description

Bayesian Inference

BI software is available in both Python and R. It aims to unify the modeling experience by integrating an intuitive model-building syntax with the flexibility of low-level abstraction coding available but also pre-build function for high-level of abstraction and including hardware-accelerated computation for improved scalability.

Currently, the package provides:

  • Data manipulation:

    • One-hot encoding
    • Conversion of index variables
    • Scaling
  • Models (Using Numpyro):

    • Linear Regression for continuous variable
    • Multiple continuous Variable
    • Interaction between variables
    • Categorical variable
    • Binomial model
    • Beta binomial
    • Poisson model
    • Gamma-Poisson
    • Multinomial
    • Dirichlet model
    • Zero inflated
    • Varying intercept
    • Varying slopes
    • Gaussian processes
    • Measuring error
    • Latent variable]
    • PCA
    • GMM
    • DPMM
    • Network model
    • Network with block model
    • Network control for data collection biases
    • BNN
  • Model diagnostics (using ARVIZ):

    • Data frame with summary statistics
    • Plot posterior densities
    • Bar plot of the autocorrelation function (ACF) for a sequence of data
    • Plot rank order statistics of chains
    • Forest plot to compare HDI intervals from a number of distributions
    • Compute the widely applicable information criterion
    • Compare models based on their expected log pointwise predictive density (ELPD)
    • Compute estimate of rank normalized split-R-hat for a set of traces
    • Calculate estimate of the effective sample size (ESS)
    • Pair plot
    • Density plot
    • ESS evolution plot

Why?

1. To learn

2. Easy Model Building:

The following linear regression model (rethinking 4.Geocentric Models): $$ \text{height} \sim \mathrm{Normal}(\mu,\sigma) $$

$$ \mu = \alpha + \beta \cdot \text{weight} $$

$$ \alpha \sim \mathrm{Normal}(178,20) $$

$$ \beta \sim \mathrm{Normal}(0,10) $$

$$ \sigma \sim \mathrm{Uniform}(0,50) $$

can be declared in the package as

from BI import bi

# Setup device------------------------------------------------
m = bi(platform='cpu')

# Import Data & Data Manipulation ------------------------------------------------
# Import
from importlib.resources import files
data_path = files('BI.resources.data') / 'Howell1.csv'
m.data(data_path, sep=';') 
m.df = m.df[m.df.age > 18] # Manipulate
m.scale(['weight']) # Scale

# Define model ------------------------------------------------
def model(weight, height):    
    a = m.dist.normal(178, 20, name = 'a') 
    b = m.dist.lognormal(0, 1, name = 'b') 
    s = m.dist.uniform(0, 50, name = 's') 
    m.normal(a + b * weight , s, obs = height) 

# Run mcmc ------------------------------------------------
m.fit(model)  # Optimize model parameters through MCMC sampling

# Summary ------------------------------------------------
m.summary() # Get posterior distributions

Todo

1. Documentation
2. DPMM prediction 
3. Survival analysis results comparaison
4. BNN load data
5. Implementation of additional MCMC sampling methods

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

bayesinference-0.0.44.tar.gz (56.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bayesinference-0.0.44-py3-none-any.whl (56.6 MB view details)

Uploaded Python 3

File details

Details for the file bayesinference-0.0.44.tar.gz.

File metadata

  • Download URL: bayesinference-0.0.44.tar.gz
  • Upload date:
  • Size: 56.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for bayesinference-0.0.44.tar.gz
Algorithm Hash digest
SHA256 b3c49e7be3e11e0811e162543ee1f652b4e95b928044ef3e603b358059ac0798
MD5 399ffb5d6dd89950dbcf5250c96fe7b1
BLAKE2b-256 cdbdbf8c06b2d4ff031ba84688efe269103ecc87742ff7735893e5aac914a2fe

See more details on using hashes here.

File details

Details for the file bayesinference-0.0.44-py3-none-any.whl.

File metadata

File hashes

Hashes for bayesinference-0.0.44-py3-none-any.whl
Algorithm Hash digest
SHA256 ae3177c27874cad0cf1edf89df63559891ec09b161201db63c714f8a43263bdd
MD5 e0342c071cfaa5dfe38e85b1808de665
BLAKE2b-256 a8c746b12a9713ddf1dde4d7d09747c77b2be1718f339f47180d07a6f7f2514f

See more details on using hashes here.

Supported by

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