bebi103.viz.parcoord

bebi103.viz.parcoord(samples=None, parameters=None, palette=None, omit=None, omit_array_entry=(), include_ppc=None, include_log_lik=None, transformation=None, color_by_chain=False, line_kwargs=None, divergence_kwargs=None, xtick_label_orientation=0.7853981633974483, **kwargs)

Make a parallel coordinate plot of MCMC samples. The x-axis is the parameter name and the y-axis is the value of the parameter, possibly transformed to so the scale of all parameters are similar.

Parameters:
  • samples (cmdstanpy.CmdStanMCMC instance, dict, or DataFrame) – Result of MCMC sampling. May be a cmdstanpy.CmdStanMCMC instance, a dictionary of two-dimensional arrays for each expectand and HMC diagnostic as output by bebi103.hmc.convert_samples(), or a pandas.DataFrame or polars.DataFrame with one row per draw and one column per expectand, optionally with ‘chain__’, ‘draw__’, and ‘divergent__’ columns. If a data frame lacks ‘chain__’ and ‘draw__’ columns, the samples are treated as a single chain with draws in row order.

  • parameters (list of str, or None (default)) – Names of parameters to include in the plot. If None, use all parameters. For multidimensional parameters, each entry must be given separately, e.g., [‘alpha[1]’, ‘alpha[2]’, ‘beta[1,1]’]. If a given entry is a 2-tuple, the first entry is the variable name, and the second entry is the label for the parameter in plots.

  • palette (list of strings of hex colors, or single hex string) – If a list, color palette to use. If a single string representing a hex color, all glyphs are colored with that color. Default is colorcet.b_glasbey_category10 from the colorcet package.

  • omit (str, re.Pattern, or iterable thereof, default None) – Variables to exclude when parameters is None. Each string entry is a glob pattern matched against the base (non-indexed) variable name; e.g. ‘theta’ omits ‘theta’ and every entry of ‘theta[1]’, ‘theta[2]’, …. A compiled re.Pattern entry is matched as a regular expression against the base name. A single string or pattern may be given instead of an iterable. Cannot be used together with parameters.

  • omit_array_entry (str or iterable of str, default ()) – Specific array entries to omit, e.g. ‘y_pred[1]’ or ‘beta[1,2]’. Each entry must include bracketed, comma-separated integer indices. A single string may be given instead of an iterable. Cannot be used together with parameters.

  • transformation (function, str, or dict, default None) – A transformation to apply to each set of samples. The function must take a single array as input and return an array as the same size. If None, nor transformation is done. If a dictionary, each key is the variable name and the corresponding value is a function for the transformation of that variable. Alternatively, if transformation is ‘minmax’, the data are scaled to range from zero to one, or if transformation is ‘rank’, the rank of the each data is used.

  • color_by_chain (bool, default False) – If True, color the lines by chain.

  • line_kwargs (dict) – Dictionary of kwargs to be passed to p.multi_line() in making the plot of non-divergent samples.

  • divergence_kwargs (dict) – Dictionary of kwargs to be passed to p.multi_line() in making the plot of divergent samples.

  • xtick_label_orientation (str or float, default π/4.) – Orientation of x tick labels. In some plots, horizontally labeled ticks will have label clashes, and this can fix that.

  • kwargs – Any kwargs to be passed to bokeh.plotting.figure() when instantiating the figure.

Returns:

output – Parallel coordinates plot.

Return type:

Bokeh plot