eulerpi.core.plotting module
Basic plotting of eulerpi sampling results.
This module provides a basic plotting functionality to visualise sampling results for eulerpi. Uses burn_in and thinning accordinng to the simulation settings.
- sample_violin_plot(model: BaseModel, reference_sample: str | PathLike | ndarray | None = None, run_name: str = 'default_run', what_to_plot: str = 'param', credibility_level: float = 0.95, num_vertical_grid_points: int = 100, axis_labels: list[str] | None = None) <module 'matplotlib.axes' from '/home/runner/work/EPI/EPI/.venv/lib/python3.10/site-packages/matplotlib/axes/__init__.py'> [source]
- Creates an overview figure with one violin plot for each marginal distribution.
Can be used for parameters and simulation results and compares reference (or true underlying) and inferred values when possible.
- Parameters:
model (BaseModel) – The model describing the mapping from parameters to data.
reference_sample (Union[str, os.PathLike, np.ndarray]) – Depending on what_to_plot, this is either the data sample used for the inference, or a reference sample of “true” parameter samples. If a string is given, it is assumed to be a path to a file containing the respective sample. (Default value = None)
run_name (str) – The name of the inference run. (Default value = “default_run”)
what_to_plot (str) – Choose between “param” and “data” to respectively visualize either the model parameters or output. (Default value = “param”)
credibility_level (float) – Defines the probability mass (between 0 and 1) that is included within each of the violin plots. Choose 1 if you do not wand any cut-off. (Default value = 0.95)
num_vertical_grid_points (int) – Defines the resolution of the vertical violin plots. Can be increased for smoother plots or decresed for faster runtime. (default value = 100)
axis_labels (list[str], optional) – The labels depicted on the ordinate of the plot. Its size needs to be identical with the dimensionality of the plotted distribution. (Default value = None)
- Returns:
The overview figure with all violin plots as a matplotlib axes object.
- Return type:
axes
Examples:
import numpy as np from eulerpi.examples.corona import Corona from eulerpi.core.inference import inference from eulerpi.core.plotting import sample_violin_plot # instantiate the Covid example model model = Corona() # generate 1000 artificial, 4D data points for the Covid example model data_scales = np.array([1.0, 5.0, 35.0, 2.0]) data = (np.random.rand(1000, 4)+1.0)*data_scales # run inference only specifying the model and the data inference(model, data) sample_violin_plot(model) sample_violin_plot(model, reference_sample = data, what_to_plot = "data", credibility_level = 0.99, axis_labels = [r"$1$", r"$2$", r"$5$", r"$15$ weeks"])