arviz_plots.plot_compare

Contents

arviz_plots.plot_compare#

arviz_plots.plot_compare(cmp_df, relative_scale=False, rotated=False, hide_top_model=False, backend=None, visuals=None, **pc_kwargs)[source]#

Summary plot for model comparison.

Models are compared based on their expected log pointwise predictive density (ELPD). Or some transformation of it, such as the mean log predictive density (MLPD) or the geometric mean predictive density (GMPD).

Higher ELPD values indicate better predictive performance.

The ELPD is estimated by Pareto smoothed importance sampling leave-one-out cross-validation (LOO). Details are presented in [1] and [2].

The ELPD can only be interpreted in relative terms. But differences in ELPD less than 4 are considered negligible [3].

Parameters:
comp_dfpandas.DataFrame

Usually this will be the result of the arviz_stats.compare function. It is assumed that the DataFrame has two columns one named elpd, mlpd, or gmpd, the other named se, and the index is the model names. Additionally, it is assumed that the first row of the DataFrame is the top model.

relative_scalebool, optional.

If True, the stats values are scaled relative to the best model. Defaults to True.

rotatedbool, optional

If True, the plot is rotated, with models on the y-axis and ELPD on the x-axis. Defaults to False.

hide_top_modelbool, optional

If True, the top model (first row of comp_df) will not appear as a point with error bars or in the axis labels. Its performance can still be accessed by the visuals ref_line and/or ref_band. Defaults to False.

backend{“bokeh”, “matplotlib”, “plotly”}

Select plotting backend. Defaults to rcParams[“plot.backend”].

visualsmapping of {strmapping or bool}, optional

Valid keys are:

  • point_estimate -> passed to scatter

  • error_bar -> passed to line

  • ref_line -> passed to hline or vline depending on the rotated parameter.

  • ref_band -> passed to hspan or vspan depending on the rotated parameter. Defaults to False.

  • similar_line -> passed to hline or vline depending on the rotated parameter. Defaults to False.

  • labels -> passed to xticks and yticks

  • title -> passed to title

  • ticklabels -> passed to yticks

**pc_kwargs

Passed to arviz_plots.PlotCollection

Returns:
PlotCollection

See also

arviz_stats.compare

Summary plot for model comparison.

arviz_stats.loo

Compute the ELPD using Pareto smoothed importance sampling Leave-one-out cross-validation method.

References

[1]

Vehtari et al. Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. Statistics and Computing. 27(5) (2017). https://doi.org/10.1007/s11222-016-9696-4. arXiv preprint https://arxiv.org/abs/1507.04544.

[2]

Vehtari et al. Pareto Smoothed Importance Sampling. Journal of Machine Learning Research, 25(72) (2024) https://jmlr.org/papers/v25/19-556.html arXiv preprint https://arxiv.org/abs/1507.02646

[3]

Sivula et al. Uncertainty in Bayesian Leave-One-Out Cross-Validation Based Model Comparison. (2025). https://doi.org/10.48550/arXiv.2008.10296