ArviZ
ArviZ is a Python package for exploratory analysis of Bayesian models. It provides tools for diagnostics, visualization, and inference data management, working with various probabilistic programming frameworks. Version 1.0.0 is the current major release, and the project has a regular, active release cadence.
Warnings
- breaking ArviZ v1.0.0 and newer require Python 3.12 or higher. Users on older Python versions (e.g., 3.10, 3.11) must upgrade their Python environment to use ArviZ 1.x.
- breaking The `rpy2` dependency and the `az.from_rpy2` function were removed in ArviZ v1.0.0 due to the internal refactor into a meta-package structure.
- gotcha Default values for several key plotting and analysis functions changed in ArviZ v0.13.0. For example, `az.plot_forest`'s `combined` argument, `az.plot_posterior`'s `kind` argument, and `az.loo`'s `pointwise` argument.
Install
-
pip install arviz
Imports
- arviz
import arviz as az
- InferenceData
import arviz as az idata = az.InferenceData(...)
Quickstart
import arviz as az
import numpy as np
# Simulate some data for demonstration
np.random.seed(42)
data = {
'theta': np.random.normal(0, 1, size=1000),
'phi': np.random.normal(5, 2, size=1000)
}
# Create a dummy InferenceData object (usually loaded from a model)
id = az.InferenceData(
posterior=az.dict_to_dataset(data),
sample_stats=az.dict_to_dataset({'lp': np.random.normal(0, 1, size=1000)})
)
# Plot a trace of the posterior samples
az.plot_trace(id, var_names=['theta'])
# Print summary statistics
print(az.summary(id, var_names=['theta']))