plot_trace()

Contents

plot_trace()#

liesel.goose.summary_viz.plot_trace(results, params=None, param_indices=None, chain_indices=None, max_chains=5, title=None, title_spacing=0.85, xlabel='Iteration', style='whitegrid', color_palette=None, ncol=3, height=3, aspect_ratio=1, save_path=None, include_warmup=False, **kwargs)[source]#

Visualizes posterior samples over time with a trace plot.

Parameters:
  • results (SamplingResults) – Result object of the sampling process. Must have a method get_posterior_samples() which extracts all samples from the posterior distribution.

  • params (Union[str, list[str], None]) – Names of the model parameters that are contained in the plot. Must coincide (default: None) with the dictionary keys of the Position with the posterior samples. If None, all parameters are included.

  • param_indices (Union[int, Sequence[int], None]) – Indices of each model parameter that are contained in the plot. Selects e.g. (default: None) beta[0] out of a beta parameter vector. A single index can be specified as an integer or a sequence containing one integer. If None, all subparameters are included.

  • chain_indices (Union[int, Sequence[int], None]) – Indices of chains for each model subparameter that are contained in the plot. (default: None) Selects e.g. chain 0 and chain 2 out of multiple chains. A single index can be specified as an integer or a sequence containing one integer. If None, all chains are included.

  • max_chains (int | None) – Upper bound how many chains are included within each subplot/facet. Avoids (default: 5) overplotting. If None, all chains contained in the results input are plotted. Always starts chain selection from the lowest chain index upwards. For selecting specific chains use the argument chain_indices.

  • title (Optional[str]) – Plot title. (default: None)

  • title_spacing (float) – Determines the margin/whitespace between the plot title (set with (default: 0.85) fig.suptitle()) and the first row of subplots/facets. Passed to the top argument of fig.subplots_adjust().

  • xlabel (str) – Label of the x-axis. (default: 'Iteration')

  • style (str) – Passed to the style argument of sns.set_theme(). Valid options are (default: 'whitegrid') "darkgrid", "whitegrid", "dark", "white", and "ticks".

  • color_palette (Union[str, list[str], dict[int, str], None]) – Passed to the palette argument of sns.relplot(). String values must be (default: None) valid inputs of sns.color_palette() such as a seaborn color palette or a matplotlib colormap. Custom colors can be set with a list of color strings or a dictionary with the chain indices as keys and color strings as values. The number of color strings must coincide with the number of plotted chains. If None, the default tab10 matplotlib colormap is chosen.

  • ncol (int) – Number of subplots/facets within each row of the grid. (default: 3)

  • height (int) – Height in inches of each subplot/facet within the grid. (default: 3)

  • aspect_ratio (int) – Ratio of width / height of each subplot/facet within the grid, i.e. width = (default: ``1) aspect_ratio * height``.

  • save_path (Optional[str]) – File path where the plot is saved. (default: None)

  • include_warmup (bool) – Include the warmup samples in the trace plot. (default: False)

  • **kwargs – Further keyword arguments passed to the seaborn relplot() function.

Return type:

FacetGrid

Returns:

A seaborn FacetGrid.