ArviZ - Exploratory analysis of Bayesian models in Python for PyStan and CmdStan

loo

#1

Hi,

I’m happy to announce that we have officially released ArviZ Python library for Exploratory analysis of Bayesian models. We have a support for PyStan and CmdStan.

pip install arviz

https://arviz-devs.github.io/arviz/

ArviZ provides a general platform for multidimensional MCMC samples called InferenceData, which is a NetCDF4 format structure build on top of the xarray dataset. In future we hope to support also Variational Inference results.

ArviZ has implemented many core visualizations for Bayesian workflow and all of these are using InferenceData as a base. The current plotting is built on top of the matplotlib and in future, we hope to support also other libraries.

We also provide general Bayesian diagnostics tools, including summary and psis-loo.

It is now the official plotting library for PyStan.

PyStan

import arviz as az
import pystan
....
fit =...
# plot trace
inference_data = az.from_pystan(fit=fit)
az.plot_trace(inference_data)

CmdStan

import arviz as az
# support for glob strings
paths = "./path_to_output/output[0-9].csv"
inference_data = az.from_cmdstan(output=paths)
az.plot_trace(inference_data)

#2

Updated instructions

PyStan

import arviz as az
import pystan
....
fit =...
# plot trace
inference_data = az.from_pystan(posterior=fit) # posterior kw is optional
az.plot_trace(inference_data)

CmdStan

import arviz as az
# support for glob strings
paths = "./path_to_output/output[0-9].csv"
inference_data = az.from_cmdstan(posterior=paths) # posterior kw is optional
az.plot_trace(inference_data)