A library to consume your fitting chains! Produce likelihood surfaces, plot your walks to check convergence, output a LaTeX table of the marginalised parameter distributions with uncertainties and significant figures all done for you, or throw in a bunch of chains from different models and perform some model selection!
Click through to the online documentation
Install via pip
:
pip install chainconsumer
Time has ticked on, and now only python 3.10 will be supported. This is because type hints are amazing.
- Clone repo
- Run
make install
- Ensure that you set your python interpreter to the
.venv/bin/python
- Code away.
I would like to thank the following people for their contribution in issues, algorithms and code snippets which have helped improve ChainConsumer:
- Simon Dupourqué (for his PRs and suggestions to make ChainConsumer better for all)
- Chris Davis (check out https://github.com/cpadavis/preliminize)
- Joe Zuntz
- Scott Dedelson
- Elizabeth Krause
- David Parkinson
- Caitlin Adams
- Tom McClintock
- Steven Murray
- J. Michael Burgess
- Matthew Kirby
- Michael Troxel
- Eduardo Rozo
- Warren Morningstar
Users on some Linux platforms have reported issues rendering plots using ChainConsumer.
The common error states that dvipng: not found
, and as per StackOverflow
post, it can be solved by explicitly install the matplotlib
dependency dvipng
via sudo apt-get install dvipng
.
If you are running on HPC or clusters where you can't install things yourself, users may run into issues where LaTeX or other optional dependencies aren't installed. In this case, set usetex=False
in configure
to request matplotlib not try to use TeX. If this does not work, also set serif=False
, which has helped some uses.
- Switch
scipy.integrate.simps
toscipy.integrate.simpsons
for compatibility with new releases
- Adding general
kwargs
toadd_marker
so one can passshow_label_in_legend
and other customisations through.
- Updating numpyro and arviz translators so you can specify variable names (
var_names
) to include or exclude. - Adding
histogram_relative_height
property to chains to control histogram height. - Adding
show_label_in_legend
so you can decide to give a chain a label but not have it pollute the legend.
- Bug fix not using labels instead of column names for parameter title summaries.
- Bug fix for chain divisions.
- Bug fix for the truth labels.
- Huge update to make full use of type hints, pydantic v2, and mkdocs
- Making
usetex=False
andserif=False
the defaults to reduce LaTeX errors.
- Adding extra padding to bin extents for KDE and smoothing
- Updating watermarking to work with matplotlib v3.0.0+
- Fixing matplotlib axis formatter issue.
- Conda-forge updates
- Adding ability to display plot as a prior (1D only, no 2D)
- Linking colorbar label font size to global label font size option. Thanks Yucheng-Zhang!
- Allowing chains to be passed in as a pandas DataFrame.
- Statsmodel update means we are now switching to Python 3 only support.
- Updating
matplotlib
dependency version for conda install. Thanks He Jia!
- Bug fix for specifying numeric
loc
tolegend_kwargs
- Added
shift_params
when adding chains.
- Potential bug fix for
log_space
feature.
- Warning the user if
configure
is called multiple times. - Allowing parameters to be a number when calling
get_latex_table
- Adding log scales when plotting.
- Adding the ability to plot a contour on an arbitrary axis via new method
plot_contour
- Removing
rainbow
option and replacing withcmap
so you can specify the cmap used, not just rainbow. - Adding
zorder
configuration option to epxlicitly order contours. - Adding extra checks to try and catch bad chains on load.
- Now restores default
rcParams
forusetex
andfont-family
after plotting. - All logging now under logger name
chainconsumer
to make it easy to hide if needed. - Formula for computing
shade_alpha
now uses sqrt(num_chains) instead of num_chains. get_latex_table
now accepts a filename input to save the parameters to.- Adding
add_covariance
to complimentadd_chain
- useful for Fisher matrix forecasts and similar. Just invert it first for me. - Adding
add_marker
to allow easy inclusion of markers in the plots.
- Adding ability to turn off chain names in
plot_summary
.
- Fixing bug with
plot_walks
that required truth values. - Fixing flaw in
configure
to allow for updating values. - Fixing bug where summary values are cached without reference to the summary statistic method.
- Adding ability to plot maximum points on 2D contour, not just global posterior maximum.
- Fixing truth dictionary mutation on
plot_walks
- Adding ability to pass in a power to raise the surface to for each chain.
- Adding methods to retrieve the maximum posterior point:
Analysis.get_max_posteriors
- Adding ability to plot maximum posterior points. Can control
marker_size
,marker_style
,marker_alpha
, and whether to plot contours, points or both. - Finishing migration of configuration options you can specify when adding chains rather than configuring all chains with
configure
.
- (Attempting to) enable fully automated releases to Github, PyPI, Zenodo and conda.
- (Attempting to) enable fully automated releases to Github, PyPI, Zenodo and conda.
- Changing default
sigma2d
toFalse
. May chance how your plots are displayed. - Allowing format specification when adding chains.
- Making
yule_walker
(and thus all ofstatsmodels
) a conditional import. - Updating minimum version of requirements to reduce issues with install.
- Fixing bug in label rendering for contour sigma labels.
- Improving parsing of
sigma
inconfigure
, such that you don't need a leading zero.
- Fixing bug in
get_correlations
.
- Changing default colour order.
- Improving behaviour of
shade_gradient
.
- Refactoring project structure.
- Updating colours for better legibility.
- Setting
shade=True
automatically ifshade_alpha
is overriden.
- Removing
bbox_inches="tight"
due to a bug in matplotlib v2.1.0. - Adding more colour shortcuts.
- Making rainbow colours slightly more visible by darkening the yellow regions.
- Can now pass a list of filenames to save out, to make generating a PNG and PDF option in one go easier
- Adding method
plot_summary
- Adding option to specify the confidence interval (area) for parameter summaries.
- Adding three extra methods for parameter summaries from Andrae 2010: max symmetric, max shortest and max central stats.
- Fixing a bug that caused ChainConsumer to crash in some cases when you specified a number of parameters.
- Fixing bug that made parameter ordering incorrect in some circumstances.
- Fixing error when plotting walks with small weights.
- Fixing issue where refactoring broke parameter blinding.
- ChainConsumer now only finds extents of relevant parameters when plotting, instead of all parameters.
- Updating extents so previous updates do something.
- Adding example and code to deal with non-TeX watermarks.
- Increasing extents again.
- Updating legend defaults.
- Code refactor.
- Can now specify which chains to plot when plotting contours.
- Adding watermark text.
- Increase control over legend with kwargs.
- Can specify legend subplot location.
- Increased legend options with coloured text.
- Added
shade_gradient
option. - Increase the amount of default extent given.
- Adding ability to blind parameters.
- Adding ability to plot contour levels, either in confidence levels or sigma.
- Changed shading defaults.
- Legend gets placed in top right corner now when
plot_hsits
isFalse
and there are only two parameters.
sigma2d
correctly defaults toTrue
now.
- Adding log_weights to the detected colour parameters.
- Contours now support 1D Gaussian levels and 2D Gaussian levels (thanks @matthewkirby).
- Adding Matched Elliptical Gaussian Kernel Density Estimator to replace statsmodels KDE.
- Fixing bug in covariance calculation when getting the LaTeX table (did not affect contours)
- Default figure size is now 1.5 inches per parameter, instead of 1. Also decreasing default font size, so that printing summaries is less likely to overlap surfaces.
- Label font size now applies to legend.
- Code quality improvements
- Documentation update
- Refactoring ChainConsumer due to growing size.
- Improve bin limits to reduce overly large bins that form when some low-weight samples are located far away from the mean.
- Fixed issue generating text with one sided distributions.
- Adding ability to specify weights or posterior as the colour parameter.
- Color scatter with uniform weights doesn't have first plot a different color.
- Adding ability to control subplot spacing.
- Adding method
plot_distributions
to quickly plot marginalised distributions.
- Fixing bug in Gelman-Rubin diagnostic. Thanks Warren!
- Moving
rc
parameters before plot creation to fix issues with parallel plot generation.
- Fixing an integer division bug where python 2 contour shading was setting to 0 alpha.
- Fixing bug where tick font size was only honoured when ticks were on an angle.
- Adding ability to specify label font size, tick font size, and whether the ticks should be on an angle.
- Bug fix for those with latest
numpy
which removed a deprecated method I was using. - Adding ability to get parameter covariance tables.
- Adding ability to get parameter correlation tables.
- Removing unnecessary debug output.
- Can remove lists of chains properly now.
- Adding ability to remove chains.
- Adding ability to plot the walks of multiple chains together.
- Removing unnecessary debug output.
- Bugfix for python 2.7
- Adding
usetex
toconfigure
method. - When plotting walks, plots weights in log space if the mean weight is less than 0.1
- Adding AIC
- Adding BIC
- Adding DIC
- Adding method to output model comparison table.
- Adding coloured scatter.
- Disallowing grid data and KDE.
- Adding more examples.
- Consolidating all configures into one method.
- Improved extent finding.
- Updating smoothing to use reflect and not constant.
- Improving
max
statistics being able to find ranges on cliff edges. - Printing parameter summaries without parameter labels.
- Removing ability to having vectorised dictionary inputs for grid data due to 2.7 compatibility issues.
- Fixing bug when smoothing grid data.
- Adding more input options.
- Grids can now be specified using a list of parameter vectors.
- Better determination of extents for data with extreme weighting.
- Able to scale figure size using float when plotting.
- Modifying API defaults for smoothing with grid data.
- Allowing both smoothing and bins to be passed in as lists.
- Adding support for grid data.
- Fixing bug in Gelman-Rubin statistic
- Improving text labels again.
- Improving text labels for high value data.
- Adding Gelman-Rubin and Geweke diagnostic methods.
- Adding options for alternate statistics.
- Updating setup so that dependencies are automatically installed.
- Modifying the
add_chain
API, so that you can pass dictionaries!
- Smarter extent tick labels and offsets.
- Adding list based line styles, widths, shading and opacity.
- Adding two more examples.
- Preconfiguring logging.
- Adding 2D Gaussian smoothing for the contour surfaces.
- Renaming
contourf
andcontourf_alpha
toshade
andshade_alpha
. - Updating some of the example plots.
- Updating package setup scripts.
- Updating package setup scripts.
- Adding markdown paper.
- Updating setup and package details
- Initial zenodo release
- Adding in smoothing, making it default
- Adding extra example to show how to remove smoothing.
- Adding in tests
- Initial PyPi push