ArviZ.jl: Exploratory analysis of Bayesian models in Julia

Build Status Build Status codecov.io Code Style: Blue

ArviZ.jl is a Julia interface to the ArviZ package for exploratory analysis of Bayesian models.

Please see ArviZ's documentation for detailed descriptions of features and usage. See for example the gallery for a sample of the plots and backends ArviZ supports.

This documentation will focus on differences between ArviZ.jl and ArviZ, applications using Julia's probabilistic programming languages (PPLs), and examples in Julia.

Purpose

Besides removing the need to explicitly import ArviZ with PyCall.jl, ArviZ.jl extends ArviZ with functionality for converting Julia types into ArviZ's InferenceData format. It also allows smoother usage with PyPlot.jl and provides functions that can be overloaded by other packages to enable their types to be used with ArviZ.

Installation

To use with the default Python environment, first install ArviZ. Then in Julia's REPL run

] add ArviZ

To install ArviZ.jl with its Python dependencies in Julia's private conda environment, in the console run

PYTHON="" julia -e 'using Pkg; Pkg.add("PyCall"); Pkg.build("PyCall"); Pkg.add("ArviZ")'

For specifying other Python versions, see the PyCall documentation.

Design

ArviZ.jl supports all of ArviZ's API, except for its Numba functionality. See ArviZ's API documentation for details.

ArviZ.jl wraps ArviZ's API functions and closely follows ArviZ's design. It also supports conversion of MCMCChains.jl's Chains as returned by Turing.jl, CmdStan.jl, StanSample.jl, and others into ArviZ's InferenceData format. See Quickstart for examples.

The package is intended to be used with PyPlot.jl.

ArviZ.jl development occurs on GitHub. Issues and pull requests are welcome.

Differences from ArviZ

In ArviZ, functions in the API are usually called with the package name prefix, (e.g. arviz.plot_posterior). In ArviZ.jl, most of the same functions are exported and therefore can be called without the prefix (e.g. plot_posterior). The exception are from_xyz converters for packages that have no (known) Julia wrappers. These functions are not exported to reduce namespace clutter.

For InferenceData inputs, summarystats replaces arviz.summary to avoid confusion with Base.summary. For arbitrary inputs and the full functionality of arviz.summary, use ArviZ.summary, which is not exported.

ArviZ.jl transparently interconverts between arviz.InferenceData and our own InferenceData, used for dispatch. InferenceData has identical usage to its Python counterpart.

Functions that in ArviZ return Pandas types here return DataFrames.jl types.

ArviZ includes the context managers rc_context and interactive_backend. ArviZ.jl includes the functions with_rc_context and with_interactive_backend, which can be used with a nearly identical syntax. with_interactive_backend here is not limited to an IPython/IJulia context.

In place of arviz.style.use and arviz.style.available, ArviZ.jl provides ArviZ.use_style and ArviZ.styles.

Extending ArviZ.jl

To use a custom data type with ArviZ.jl, simply overload convert_to_inference_data to convert your input(s) to an InferenceData.

Known Issues

ArviZ.jl uses PyCall.jl to wrap ArviZ. At the moment, Julia segfaults if Numba is imported, which ArviZ does if it is available. For the moment, the workaround is to specify a Python version that doesn't have Numba installed. See this issue for more details.