Visualize¶
pypesto comes with various visualization routines. To use these, import pypesto.visualize.
-
class
pypesto.visualize.
ReferencePoint
(reference=None, x=None, fval=None, color=None, legend=None)[source]¶ Bases:
dict
Reference point for plotting. Should contain a parameter value and an objective function value, may also contain a color and a legend.
Can be used like a dict.
-
x
¶ Reference parameters.
- Type
ndarray
-
color
¶ Color which should be used for reference point.
- Type
RGBA, optional
-
auto_color
¶ flag indicating whether color for this reference point should be assigned automatically or whether it was assigned by user
- Type
boolean
-
-
pypesto.visualize.
assign_clustered_colors
(vals, balance_alpha=True, highlight_global=True)[source]¶ Cluster and assign colors.
- Parameters
vals (numeric list or array) – List to be clustered and assigned colors.
balance_alpha (bool (optional)) – Flag indicating whether alpha for large clusters should be reduced to avoid overplotting (default: True)
highlight_global (bool (optional)) – flag indicating whether global optimum should be highlighted
- Returns
colors – One for each element in ‘vals’.
- Return type
list of RGBA
-
pypesto.visualize.
assign_clusters
(vals)[source]¶ Find clustering.
- Parameters
vals (numeric list or array) – List to be clustered.
- Returns
clust (numeric list) – Indicating the corresponding cluster of each element from ‘vals’.
clustsize (numeric list) – Size of clusters, length equals number of clusters.
-
pypesto.visualize.
assign_colors
(vals, colors=None, balance_alpha=True, highlight_global=True)[source]¶ Assign colors or format user specified colors.
- Parameters
vals (numeric list or array) – List to be clustered and assigned colors.
colors (list, or RGBA, optional) – list of colors, or single color
balance_alpha (bool (optional)) – Flag indicating whether alpha for large clusters should be reduced to avoid overplotting (default: True)
highlight_global (bool (optional)) – flag indicating whether global optimum should be highlighted
- Returns
colors – One for each element in ‘vals’.
- Return type
list of RGBA
-
pypesto.visualize.
create_references
(references=None, x=None, fval=None, color=None, legend=None) → List[pypesto.visualize.reference_points.ReferencePoint][source]¶ This function creates a list of reference point objects from user inputs
- Parameters
references (ReferencePoint or dict or list, optional) – Will be converted into a list of RefPoints
x (ndarray, optional) – Parameter vector which should be used for reference point
fval (float, optional) – Objective function value which should be used for reference point
color (RGBA, optional) – Color which should be used for reference point.
legend (str) – legend text for reference point
- Returns
colors – One for each element in ‘vals’.
- Return type
list of RGBA
-
pypesto.visualize.
delete_nan_inf
(fvals: numpy.ndarray, x: Optional[numpy.ndarray] = None, xdim: Optional[int] = 1) → Tuple[numpy.ndarray, numpy.ndarray][source]¶ Delete nan and inf values in fvals. If parameters ‘x’ are passed, also the corresponding entries are deleted.
- Parameters
x – array of parameters
fvals – array of fval
xdim – dimension of x, in case x dimension cannot be inferred
- Returns
x – array of parameters without nan or inf
fvals – array of fval without nan or inf
-
pypesto.visualize.
ensemble_crosstab_scatter_lowlevel
(dataset: numpy.ndarray, component_labels: Optional[Sequence[str]] = None, **kwargs)[source]¶ Plot cross-classification table of scatter plots for different coordinates. Lowlevel routine for multiple UMAP and PCA plots, but can also be used to visualize, e.g., parameter traces across optimizer runs
- Parameters
dataset – array of data points to be shown as scatter plot
component_labels – labels for the x-axes and the y-axes
- Returns
A dictionary of plot axes.
- Return type
axs
-
pypesto.visualize.
ensemble_identifiability
(ensemble: pypesto.ensemble.ensemble.Ensemble, ax: Optional[matplotlib.axes._axes.Axes] = None, size: Optional[Tuple[float]] = (12, 6))[source]¶ Plots an overview about how many parameters hit the parameter bounds based on a ensemble of parameters. confidence intervals/credible ranges are computed via the ensemble mean plus/minus 1 standard deviation. This highlevel routine expects a ensemble object as input.
- Parameters
ensemble – ensemble of parameter vectors (from pypesto.ensemble)
ax – Axes object to use.
size – Figure size (width, height) in inches. Is only applied when no ax object is specified
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes
-
pypesto.visualize.
ensemble_scatter_lowlevel
(dataset, ax: Optional[matplotlib.axes._axes.Axes] = None, size: Optional[Tuple[float]] = (12, 6), x_label: str = 'component 1', y_label: str = 'component 2', color_by: Optional[Sequence[float]] = None, color_map: str = 'viridis', background_color: Tuple[float, float, float, float] = (0.0, 0.0, 0.0, 1.0), marker_type: str = '.', scatter_size: float = 0.5, invert_scatter_order: bool = False)[source]¶ Create a scatter plot
- Parameters
dataset – array of data points in reduced dimension
ax – Axes object to use.
size – Figure size (width, height) in inches. Is only applied when no ax object is specified
x_label – The x-axis label
y_label – The y-axis label
color_by – A sequence/list of floats, which specify the color in the colormap
color_map – A colormap name known to pyplot
background_color – Background color of the axes object (defaults to black)
marker_type – Type of plotted markers
scatter_size – Size of plotted markers
invert_scatter_order – Specifies the order of plotting the scatter points, can be important in case of overplotting
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes
-
pypesto.visualize.
optimization_run_properties_one_plot
(results: pypesto.result.Result, properties_to_plot: Optional[List[str]] = None, size: Tuple[float, float] = (18.5, 10.5), start_indices: Optional[Union[int, Iterable[int]]] = None, colors: Optional[Union[List[float], List[List[float]]]] = None, legends: Optional[Union[str, List[str]]] = None, plot_type: str = 'line') → matplotlib.axes._axes.Axes[source]¶ Plot stats for all optimization properties specified in properties_to_plot on one plot.
- Parameters
results – Optimization result obtained by ‘optimize.py’ or list of those
properties_to_plot – Optimization run properties that should be plotted
size – Figure size (width, height) in inches. Is only applied when no ax object is specified
start_indices – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plotted
colors – List of RGBA colors (one color per property in properties_to_plot), or single RGBA color. If not set and one result, clustering is done and colors are assigned automatically
legends – Labels, one label per optimization property
plot_type – Specifies plot type. Possible values: ‘line’ and ‘hist’
Examples
- optimization_properties_per_multistart(
result1, properties_to_plot=[‘time’], colors=[.5, .9, .9, .3])
- optimization_properties_per_multistart(
result1, properties_to_plot=[‘time’, ‘n_grad’], colors=[[.5, .9, .9, .3], [.2, .1, .9, .5]])
-
pypesto.visualize.
optimization_run_properties_per_multistart
(results: Union[pypesto.result.Result, Sequence[pypesto.result.Result]], properties_to_plot: Optional[List[str]] = None, size: Tuple[float, float] = (18.5, 10.5), start_indices: Optional[Union[int, Iterable[int]]] = None, colors: Optional[Union[List[float], List[List[float]]]] = None, legends: Optional[Union[str, List[str]]] = None, plot_type: str = 'line') → Dict[str, matplotlib.axes._subplots.AxesSubplot][source]¶ One plot per optimization property in properties_to_plot.
- Parameters
results – Optimization result obtained by ‘optimize.py’ or list of those
properties_to_plot – Optimization run properties that should be plotted
size – Figure size (width, height) in inches. Is only applied when no ax object is specified
start_indices – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plotted
colors – List of RGBA colors (one color per result in results), or single RGBA color. If not set and one result, clustering is done and colors are assigned automatically
legends – Labels for line plots, one label per result object
plot_type – Specifies plot type. Possible values: ‘line’ and ‘hist’
- Returns
ax
The plot axes.
Examples
- optimization_properties_per_multistart(
result1, properties_to_plot=[‘time’], colors=[.5, .9, .9, .3])
- optimization_properties_per_multistart(
[result1, result2], properties_to_plot=[‘time’], colors=[[.5, .9, .9, .3], [.2, .1, .9, .5]])
- optimization_properties_per_multistart(
result1, properties_to_plot=[‘time’, ‘n_grad’], colors=[.5, .9, .9, .3])
- optimization_properties_per_multistart(
[result1, result2], properties_to_plot=[‘time’, ‘n_fval’], colors=[[.5, .9, .9, .3], [.2, .1, .9, .5]])
-
pypesto.visualize.
optimization_run_property_per_multistart
(results: Union[pypesto.result.Result, Sequence[pypesto.result.Result]], opt_run_property: str, axes: Optional[matplotlib.axes._axes.Axes] = None, size: Tuple[float, float] = (18.5, 10.5), start_indices: Optional[Union[int, Iterable[int]]] = None, colors: Optional[Union[List[float], List[List[float]]]] = None, legends: Optional[Union[str, List[str]]] = None, plot_type: str = 'line') → matplotlib.axes._axes.Axes[source]¶ Plot stats for an optimization run property specified by opt_run_property. It is possible to plot a histogram or a line plot. In a line plot, on the x axis are the numbers of the multistarts, where the multistarts are ordered with respect to a function value. On the y axis of the line plot the value of the corresponding parameter for each multistart is displayed.
- Parameters
opt_run_property – optimization run property to plot. One of the ‘time’, ‘n_fval’, ‘n_grad’, ‘n_hess’, ‘n_res’, ‘n_sres’
results – Optimization result obtained by ‘optimize.py’ or list of those
axes – Axes object to use
size – Figure size (width, height) in inches. Is only applied when no ax object is specified
start_indices – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plotted
colors – List of RGBA colors (one color per result in results), or single RGBA color. If not set and one result, clustering is done and colors are assigned automatically
legends – Labels for line plots, one label per result object
plot_type – Specifies plot type. Possible values: ‘line’, ‘hist’, ‘both’
- Returns
The plot axes.
- Return type
ax
-
pypesto.visualize.
optimizer_convergence
(result: pypesto.result.Result, ax: Optional[matplotlib.axes._axes.Axes] = None, xscale: str = 'symlog', yscale: str = 'log', size: Tuple[float] = (18.5, 10.5)) → matplotlib.axes._axes.Axes[source]¶ Scatter plot of function values and gradient values at the end of optimization. Optimizer exit-message is encoded by color. Can help identifying convergence issues in optimization and guide tolerance refinement etc.
- Parameters
result – Optimization result obtained by ‘optimize.py’
ax – Axes object to use.
size – Figure size (width, height) in inches. Is only applied when no ax object is specified
xscale – Scale for x-axis
yscale – Scale for y-axis
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes
-
pypesto.visualize.
optimizer_history
(results, ax=None, size=(18.5, 10.5), trace_x='steps', trace_y='fval', scale_y='log10', offset_y=None, colors=None, y_limits=None, start_indices=None, reference=None, legends=None)[source]¶ Plot history of optimizer. Can plot either the history of the cost function or of the gradient norm, over either the optimizer steps or the computation time.
- Parameters
results (pypesto.Result or list) – Optimization result obtained by ‘optimize.py’ or list of those
ax (matplotlib.Axes, optional) – Axes object to use.
size (tuple, optional) – Figure size (width, height) in inches. Is only applied when no ax object is specified
trace_x (str, optional) – What should be plotted on the x-axis? Possibilities: ‘time’, ‘steps’ Default: ‘steps’
trace_y (str, optional) – What should be plotted on the y-axis? Possibilities: ‘fval’, ‘gradnorm’, ‘stepsize’ Default: ‘fval’
scale_y (str, optional) – May be logarithmic or linear (‘log10’ or ‘lin’)
offset_y (float, optional) – Offset for the y-axis-values, as these are plotted on a log10-scale Will be computed automatically if necessary
colors (list, or RGBA, optional) – list of colors, or single color color or list of colors for plotting. If not set, clustering is done and colors are assigned automatically
y_limits (float or ndarray, optional) – maximum value to be plotted on the y-axis, or y-limits
start_indices (list or int) – list of integers specifying the multistart to be plotted or int specifying up to which start index should be plotted
reference (list, optional) – List of reference points for optimization results, containing et least a function value fval
legends (list or str) – Labels for line plots, one label per result object
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes
-
pypesto.visualize.
optimizer_history_lowlevel
(vals, scale_y='log10', colors=None, ax=None, size=(18.5, 10.5), x_label='Optimizer steps', y_label='Objective value', legend_text=None)[source]¶ Plot optimizer history using list of numpy arrays.
- Parameters
vals (list of numpy arrays) – list of 2xn-arrays (x_values and y_values of the trace)
scale_y (str, optional) – May be logarithmic or linear (‘log10’ or ‘lin’)
colors (list, or RGBA, optional) – list of colors, or single color color or list of colors for plotting. If not set, clustering is done and colors are assigned automatically
ax (matplotlib.Axes, optional) – Axes object to use.
size (tuple, optional) – see waterfall
x_label (str) – label for x-axis
y_label (str) – label for y-axis
legend_text (str) – Label for line plots
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes
-
pypesto.visualize.
parameter_hist
(result: pypesto.result.Result, parameter_name: str, bins: Union[int, str] = 'auto', ax: Optional[matplotlib.Axes] = None, size: Optional[Tuple[float]] = (18.5, 10.5), color: Optional[List[float]] = None, start_indices: Optional[Union[int, List[int]]] = None)[source]¶ Plot parameter values as a histogram.
- Parameters
result – Optimization result obtained by ‘optimize.py’
parameter_name – The name of the parameter that should be plotted
bins – Specifies bins of the histogram
ax – Axes object to use
size – Figure size (width, height) in inches. Is only applied when no ax object is specified
color – RGBA color.
start_indices – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plotted
- Returns
ax
The plot axes.
-
pypesto.visualize.
parameters
(results: Union[pypesto.result.Result, Sequence[pypesto.result.Result]], ax: Optional[matplotlib.axes._axes.Axes] = None, parameter_indices: Union[str, Sequence[int]] = 'free_only', lb: Optional[Union[numpy.ndarray, List[float]]] = None, ub: Optional[Union[numpy.ndarray, List[float]]] = None, size: Optional[Tuple[float, float]] = None, reference: Optional[List[pypesto.visualize.reference_points.ReferencePoint]] = None, colors: Optional[Union[List[float], List[List[float]]]] = None, legends: Optional[Union[str, List[str]]] = None, balance_alpha: bool = True, start_indices: Optional[Union[int, Iterable[int]]] = None) → matplotlib.axes._axes.Axes[source]¶ Plot parameter values.
- Parameters
results – Optimization result obtained by ‘optimize.py’ or list of those
ax – Axes object to use.
parameter_indices – Specifies which parameters should be plotted. Allowed string values are ‘all’ (both fixed and free parameters will be plotted) and ‘free_only’ (only free parameters will be plotted)
lb – If not None, override result.problem.lb, problem.problem.ub. Dimension either result.problem.dim or result.problem.dim_full.
ub – If not None, override result.problem.lb, problem.problem.ub. Dimension either result.problem.dim or result.problem.dim_full.
size – Figure size (width, height) in inches. Is only applied when no ax object is specified
reference – List of reference points for optimization results, containing at least a function value fval
colors – list of RGBA colors, or single RGBA color If not set, clustering is done and colors are assigned automatically
legends – Labels for line plots, one label per result object
balance_alpha – Flag indicating whether alpha for large clusters should be reduced to avoid overplotting (default: True)
start_indices – list of integers specifying the multistarts to be plotted or int specifying up to which start index should be plotted
- Returns
The plot axes.
- Return type
ax
-
pypesto.visualize.
parameters_lowlevel
(xs: Sequence[Union[numpy.ndarray, List[float]]], fvals: Union[numpy.ndarray, List[float]], lb: Optional[Union[numpy.ndarray, List[float]]] = None, ub: Optional[Union[numpy.ndarray, List[float]]] = None, x_labels: Optional[Iterable[str]] = None, ax: Optional[matplotlib.axes._axes.Axes] = None, size: Optional[Tuple[float, float]] = None, colors: Optional[Sequence[Union[numpy.ndarray, List[float]]]] = None, linestyle: str = '-', legend_text: Optional[str] = None, balance_alpha: bool = True) → matplotlib.axes._axes.Axes[source]¶ Plot parameters plot using list of parameters.
- Parameters
xs – Including optimized parameters for each startpoint. Shape: (n_starts, dim).
fvals – Function values. Needed to assign cluster colors.
lb – The lower and upper bounds.
ub – The lower and upper bounds.
x_labels – Labels to be used for the parameters.
ax – Axes object to use.
size – see parameters
colors – One for each element in ‘fvals’.
linestyle – linestyle argument for parameter plot
legend_text – Label for line plots
balance_alpha – Flag indicating whether alpha for large clusters should be reduced to avoid overplotting (default: True)
- Returns
The plot axes.
- Return type
ax
-
pypesto.visualize.
process_offset_y
(offset_y: Optional[float], scale_y: str, min_val: float) → float[source]¶ compute offset for y-axis, depend on user settings
- Parameters
offset_y – value for offsetting the later plotted values, in order to ensure positivity if a semilog-plot is used
scale_y – Can be ‘lin’ or ‘log10’, specifying whether values should be plotted on linear or on log10-scale
min_val – Smallest value to be plotted
- Returns
offset_y – value for offsetting the later plotted values, in order to ensure positivity if a semilog-plot is used
- Return type
-
pypesto.visualize.
process_result_list
(results, colors=None, legends=None)[source]¶ assigns colors and legends to a list of results, check user provided lists
- Parameters
results (list or pypesto.Result) – list of pypesto.Result objects or a single pypesto.Result
colors (list, optional) – list of RGBA colors
- Returns
results (list of pypesto.Result) – list of pypesto.Result objects
colors (list of RGBA) – One for each element in ‘results’.
legends (list of str) – labels for line plots
-
pypesto.visualize.
process_y_limits
(ax, y_limits)[source]¶ apply user specified limits of y-axis
- Parameters
ax (matplotlib.Axes, optional) – Axes object to use.
y_limits (ndarray) – y_limits, minimum and maximum, for current axes object
- Returns
ax – Axes object to use.
- Return type
matplotlib.Axes, optional
-
pypesto.visualize.
profile_cis
(result: pypesto.result.Result, confidence_level: float = 0.95, profile_indices: Optional[Sequence[int]] = None, profile_list: int = 0, color: Union[str, tuple] = 'C0', show_bounds: bool = False, ax: Optional[matplotlib.axes._axes.Axes] = None) → matplotlib.axes._axes.Axes[source]¶ Plot approximate confidence intervals based on profiles.
- Parameters
result – The result object after profiling.
confidence_level – The confidence level in (0,1), which is translated to an approximate threshold assuming a chi2 distribution, using pypesto.profile.chi2_quantile_to_ratio.
profile_indices – List of integer values specifying which profiles should be plotted. Defaults to the indices for which profiles were generated in profile list profile_list.
profile_list – Index of the profile list to be used.
color – Main plot color.
show_bounds – Whether to show, and extend the plot to, the lower and upper bounds.
ax – Axes object to use. Default: Create a new one.
-
pypesto.visualize.
profile_lowlevel
(fvals, ax=None, size: Tuple[float, float] = (18.5, 6.5), color=None, legend_text: Optional[str] = None, show_bounds: bool = False, lb: Optional[float] = None, ub: Optional[float] = None)[source]¶ Lowlevel routine for plotting one profile, working with a numpy array only
- Parameters
fvals (numeric list or array) – Values to plot.
ax (matplotlib.Axes, optional) – Axes object to use.
size (tuple, optional) – Figure size (width, height) in inches. Is only applied when no ax object is specified.
color (RGBA, optional) – Color for profiles in plot.
legend_text (str) – Label for line plots.
show_bounds – Whether to show, and extend the plot to, the lower and upper bounds.
lb – Lower bound.
ub – Upper bound.
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes
-
pypesto.visualize.
profiles
(results: Union[pypesto.result.Result, Sequence[pypesto.result.Result]], ax=None, profile_indices: Optional[Sequence[int]] = None, size: Sequence[float] = (18.5, 6.5), reference: Optional[Union[pypesto.visualize.reference_points.ReferencePoint, Sequence[pypesto.visualize.reference_points.ReferencePoint]]] = None, colors=None, legends: Optional[Sequence[str]] = None, x_labels: Optional[Sequence[str]] = None, profile_list_ids: Union[int, Sequence[int]] = 0, ratio_min: float = 0.0, show_bounds: bool = False)[source]¶ Plot classical 1D profile plot (using the posterior, e.g. Gaussian like profile)
- Parameters
results (list or pypesto.Result) – List of or single pypesto.Result after profiling.
ax (list of matplotlib.Axes, optional) – List of axes objects to use.
profile_indices (list of integer values) – List of integer values specifying which profiles should be plotted.
size (tuple, optional) – Figure size (width, height) in inches. Is only applied when no ax object is specified.
reference (list, optional) – List of reference points for optimization results, containing at least a function value fval.
colors (list, or RGBA, optional) – List of colors, or single color.
legends (list or str, optional) – Labels for line plots, one label per result object.
x_labels (list of str) – Labels for parameter value axes (e.g. parameter names).
profile_list_ids (int or list of ints, optional) – Index or list of indices of the profile lists to be used for profiling.
ratio_min – Minimum ratio below which to cut off.
show_bounds – Whether to show, and extend the plot to, the lower and upper bounds.
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes
-
pypesto.visualize.
profiles_lowlevel
(fvals, ax=None, size: Tuple[float, float] = (18.5, 6.5), color=None, legend_text: Optional[str] = None, x_labels=None, show_bounds: bool = False, lb_full=None, ub_full=None)[source]¶ Lowlevel routine for profile plotting, working with a list of arrays only, opening different axes objects in case
- Parameters
fvals (numeric list or array) – Values to plot.
ax (list of matplotlib.Axes, optional) – List of axes object to use.
size (tuple, optional) – Figure size (width, height) in inches. Is only applied when no ax object is specified.
size – Figure size (width, height) in inches. Is only applied when no ax object is specified.
color (RGBA, optional) – Color for profiles in plot.
legend_text (List[str]) – Label for line plots.
legend_text – Label for line plots.
show_bounds – Whether to show, and extend the plot to, the lower and upper bounds.
lb_full – Lower bound.
ub_full – Upper bound.
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes
-
pypesto.visualize.
projection_scatter_pca
(pca_coordinates: numpy.ndarray, components: Sequence[int] = (0, 1), **kwargs)[source]¶ Plot a scatter plots for PCA coordinates. Creates either one or multiple scatter plots, depending on the number of coordinates passed to it.
- Parameters
pca_coordinates – array of pca coordinates (returned as first output by the routine get_pca_representation) to be shown as scatter plot
components – Components to be plotted (corresponds to columns of pca_coordinates)
- Returns
Either one axes object, or a dictionary of plot axes (depending on the number of coordinates passed)
- Return type
axs
-
pypesto.visualize.
projection_scatter_umap
(umap_coordinates: numpy.ndarray, components: Sequence[int] = (0, 1), **kwargs)[source]¶ Plot a scatter plots for UMAP coordinates. Creates either one or multiple scatter plots, depending on the number of coordinates passed to it.
- Parameters
umap_coordinates – array of umap coordinates (returned as first output by the routine get_umap_representation) to be shown as scatter plot
components – Components to be plotted (corresponds to columns of umap_coordinates)
- Returns
Either one axes object, or a dictionary of plot axes (depending on the number of coordinates passed)
- Return type
axs
-
pypesto.visualize.
projection_scatter_umap_original
(umap_object: None, color_by: Optional[Sequence[float]] = None, components: Sequence[int] = (0, 1), **kwargs)[source]¶ Wrapper around umap.plot.points. Similar to projection_scatter_umap, but uses the original plotting routine from umap.plot.
- Parameters
umap_object – umap object (returned as second output by get_umap_representation) to be shown as scatter plot
color_by – A sequence/list of floats, which specify the color in the colormap
components – Components to be plotted (corresponds to columns of umap_coordinates)
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes
-
pypesto.visualize.
sampling_1d_marginals
(result: pypesto.result.Result, i_chain: int = 0, par_indices: Optional[Sequence[int]] = None, stepsize: int = 1, plot_type: str = 'both', bw: str = 'scott', suptitle: Optional[str] = None, size: Optional[Tuple[float, float]] = None)[source]¶ Plot marginals.
- Parameters
result – The pyPESTO result object with filled sample result.
i_chain – Which chain to plot. Default: First chain.
par_indices (list of integer values) – List of integer values specifying which parameters to plot. Default: All parameters are shown.
stepsize – Only one in stepsize values is plotted.
plot_type ({'hist'|'kde'|'both'}) – Specify whether to plot a histogram (‘hist’), a kernel density estimate (‘kde’), or both (‘both’).
bw ({'scott', 'silverman' | scalar | pair of scalars}) – Kernel bandwidth method.
suptitle – Figure super title.
size – Figure size in inches.
- Returns
ax
- Return type
matplotlib-axes
-
pypesto.visualize.
sampling_fval_traces
(result: pypesto.result.Result, i_chain: int = 0, full_trace: bool = False, stepsize: int = 1, title: Optional[str] = None, size: Optional[Tuple[float, float]] = None, ax: Optional[matplotlib.axes._axes.Axes] = None)[source]¶ Plot log-posterior (=function value) over iterations.
- Parameters
result – The pyPESTO result object with filled sample result.
i_chain – Which chain to plot. Default: First chain.
full_trace – Plot the full trace including warm up. Default: False.
stepsize – Only one in stepsize values is plotted.
title – Axes title.
size (ndarray) – Figure size in inches.
ax – Axes object to use.
- Returns
The plot axes.
- Return type
ax
-
pypesto.visualize.
sampling_parameter_cis
(result: pypesto.result.Result, alpha: Optional[Sequence[int]] = None, step: float = 0.05, show_median: bool = True, title: Optional[str] = None, size: Optional[Tuple[float, float]] = None, ax: Optional[matplotlib.axes._axes.Axes] = None) → matplotlib.axes._axes.Axes[source]¶ Plot MCMC-based parameter credibility intervals for one or more credibility levels.
- Parameters
result – The pyPESTO result object with filled sample result.
alpha – List of lower tail probabilities, defaults to 95% interval.
step – Height of boxes for projectile plot, defaults to 0.05.
show_median – Plot the median of the MCMC chain. Default: True.
title – Axes title.
size (ndarray) – Figure size in inches.
ax – Axes object to use.
- Returns
The plot axes.
- Return type
ax
-
pypesto.visualize.
sampling_parameter_traces
(result: pypesto.result.Result, i_chain: int = 0, par_indices: Optional[Sequence[int]] = None, full_trace: bool = False, stepsize: int = 1, use_problem_bounds: bool = True, suptitle: Optional[str] = None, size: Optional[Tuple[float, float]] = None, ax: Optional[matplotlib.axes._axes.Axes] = None)[source]¶ Plot parameter values over iterations.
- Parameters
result – The pyPESTO result object with filled sample result.
i_chain – Which chain to plot. Default: First chain.
par_indices (list of integer values) – List of integer values specifying which parameters to plot. Default: All parameters are shown.
full_trace – Plot the full trace including warm up. Default: False.
stepsize – Only one in stepsize values is plotted.
use_problem_bounds – Defines if the y-limits shall be the lower and upper bounds of parameter estimation problem.
suptitle – Figure suptitle.
size – Figure size in inches.
ax – Axes object to use.
- Returns
The plot axes.
- Return type
ax
-
pypesto.visualize.
sampling_prediction_trajectories
(ensemble_prediction: pypesto.ensemble.ensemble.EnsemblePrediction, levels: Union[float, Sequence[float]], title: Optional[str] = None, size: Optional[Tuple[float, float]] = None, axes: Optional[matplotlib.axes._axes.Axes] = None, labels: Optional[Dict[str, str]] = None, axis_label_padding: int = 50, groupby: str = 'condition', condition_gap: float = 0.01, condition_ids: Optional[Sequence[str]] = None, output_ids: Optional[Sequence[str]] = None) → matplotlib.axes._axes.Axes[source]¶ Plot MCMC-based prediction credibility intervals for the model states or outputs. One or various credibility levels can be depicted. Plots are grouped by condition.
- Parameters
result – The pyPESTO result object with filled sample result.
levels – Credibility levels, e.g. [95] for a 95% credibility interval. See the
_get_level_percentiles()
method for a description of how these levels are handled, and current limitations.title – Axes title.
size (ndarray) – Figure size in inches.
axes – Axes object to use.
labels – Keys should be ensemble output IDs, values should be the desired label for that output. Defaults to output IDs.
axis_label_padding – Pixels between axis labels and plots.
groupby – Group plots by pypesto.predict.constants.OUTPUT or pypesto.predict.constants.CONDITION.
condition_gap – Gap between conditions when groupby == pypesto.predict.constants.CONDITION.
condition_ids – If provided, only data for the provided condition IDs will be plotted.
output_ids – If provided, only data for the provided output IDs will be plotted.
- Returns
The plot axes.
- Return type
axes
-
pypesto.visualize.
sampling_scatter
(result: pypesto.result.Result, i_chain: int = 0, stepsize: int = 1, suptitle: Optional[str] = None, diag_kind: str = 'kde', size: Optional[Tuple[float, float]] = None)[source]¶ Parameter scatter plot.
- Parameters
result – The pyPESTO result object with filled sample result.
i_chain – Which chain to plot. Default: First chain.
stepsize – Only one in stepsize values is plotted.
suptitle – Figure super title.
diag_kind – Visualization mode for marginal densities {‘auto’, ‘hist’, ‘kde’, None}
size – Figure size in inches.
- Returns
The plot axes.
- Return type
ax
-
pypesto.visualize.
waterfall
(results: Union[pypesto.result.Result, Sequence[pypesto.result.Result]], ax: Optional[matplotlib.axes._axes.Axes] = None, size: Optional[Tuple[float]] = (18.5, 10.5), y_limits: Optional[Tuple[float]] = None, scale_y: Optional[str] = 'log10', offset_y: Optional[float] = None, start_indices: Optional[Union[Sequence[int], int]] = None, reference: Optional[Sequence[pypesto.visualize.reference_points.ReferencePoint]] = None, colors: Optional[Union[Tuple[float, float, float, float], Sequence[Tuple[float, float, float, float]]]] = None, legends: Optional[Union[Sequence[str], str]] = None)[source]¶ Plot waterfall plot.
- Parameters
results – Optimization result obtained by ‘optimize.py’ or list of those
ax (matplotlib.Axes, optional) – Axes object to use.
size – Figure size (width, height) in inches. Is only applied when no ax object is specified
y_limits (float or ndarray, optional) – maximum value to be plotted on the y-axis, or y-limits
scale_y – May be logarithmic or linear (‘log10’ or ‘lin’)
offset_y – offset for the y-axis, if it is supposed to be in log10-scale
start_indices – Integers specifying the multistart to be plotted or int specifying up to which start index should be plotted
reference – Reference points for optimization results, containing at least a function value fval
colors – Colors or single color for plotting. If not set, clustering is done and colors are assigned automatically
legends – Labels for line plots, one label per result object
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes
-
pypesto.visualize.
waterfall_lowlevel
(fvals, scale_y='log10', offset_y=0.0, ax=None, size=(18.5, 10.5), colors=None, legend_text=None)[source]¶ Plot waterfall plot using list of function values.
- Parameters
fvals (numeric list or array) – Including values need to be plotted.
scale_y (str, optional) – May be logarithmic or linear (‘log10’ or ‘lin’)
offset_y – offset for the y-axis, if it is supposed to be in log10-scale
ax (matplotlib.Axes, optional) – Axes object to use.
size (tuple, optional) – see waterfall
colors (list, or RGBA, optional) – list of colors, or single color color or list of colors for plotting. If not set, clustering is done and colors are assigned automatically
legend_text (str) – Label for line plots
- Returns
ax – The plot axes.
- Return type
matplotlib.Axes