pypesto.visualize
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[ReferencePoint] [source]
Create 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: ndarray, x: ndarray | None = None, xdim: int | None = 1, magnitude_bound: float | None = inf) Tuple[ndarray, 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
magnitude_bound – any values with a magnitude (absolute value) larger than the magnitude_bound are also deleted
- Returns:
x – array of parameters without nan or inf
fvals – array of fval without nan or inf
- pypesto.visualize.ensemble_crosstab_scatter_lowlevel(dataset: ndarray, component_labels: Sequence[str] | None = 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: Ensemble, ax: Axes | None = None, size: Tuple[float] | None = (12, 6))[source]
Visualize identifiablity of parameter ensemble.
Plot 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: Axes | None = None, size: Tuple[float] | None = (12, 6), x_label: str = 'component 1', y_label: str = 'component 2', color_by: Sequence[float] | None = 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: Result, properties_to_plot: List[str] | None = None, size: Tuple[float, float] = (18.5, 10.5), start_indices: int | Iterable[int] | None = None, colors: List[float] | List[List[float]] | None = None, legends: str | List[str] | None = None, plot_type: str = 'line') Axes [source]
Plot stats for allproperties 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’
- Returns:
The plot axes.
- Return type:
ax
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: Result | Sequence[Result], properties_to_plot: List[str] | None = None, size: Tuple[float, float] = (18.5, 10.5), start_indices: int | Iterable[int] | None = None, colors: List[float] | List[List[float]] | None = None, legends: str | List[str] | None = None, plot_type: str = 'line') Dict[str, Axes] [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: Result | Sequence[Result], opt_run_property: str, axes: Axes | None = None, size: Tuple[float, float] = (18.5, 10.5), start_indices: int | Iterable[int] | None = None, colors: List[float] | List[List[float]] | None = None, legends: str | List[str] | None = None, plot_type: str = 'line') 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:
axes
- pypesto.visualize.optimization_scatter(result: Result, parameter_indices: str | Sequence[int] = 'free_only', start_indices: int | Iterable[int] | None = None, diag_kind: str = 'kde', suptitle: str | None = None, size: Tuple[float, float] | None = None, show_bounds: bool = False)[source]
Plot a scatter plot of all pairs of parameters for the given starts.
- Parameters:
result – Optimization result obtained by ‘optimize.py’.
parameter_indices – List of integers specifying the parameters to be considered.
start_indices – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plotted.
diag_kind – Visualization mode for marginal densities {‘auto’, ‘hist’, ‘kde’, None}.
suptitle – Title of the plot.
size – Size of the plot.
show_bounds – Whether to show the parameter bounds.
- Returns:
The plot axis.
- Return type:
ax
- pypesto.visualize.optimizer_convergence(result: Result, ax: Axes | None = None, xscale: str = 'symlog', yscale: str = 'log', size: Tuple[float] = (18.5, 10.5)) Axes [source]
Visualize to help spotting convergence issues.
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: Result | List[Result], ax: Axes | None = None, size: Tuple = (18.5, 10.5), trace_x: str = 'steps', trace_y: str = 'fval', scale_y: str = 'log10', offset_y: float | None = None, colors: Tuple[float, float, float, float] | List[Tuple[float, float, float, float]] | None = None, y_limits: float | List[float] | ndarray | None = None, start_indices: int | List[int] | None = None, reference: ReferencePoint | dict | List[ReferencePoint] | List[dict] | None = None, legends: str | List[str] | None = None) Axes [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 – Optimization result obtained by ‘optimize.py’ or list of those
ax – Axes object to use.
size (tuple, optional) – Figure size (width, height) in inches. Is only applied when no ax object is specified
trace_x – What should be plotted on the x-axis? Possibilities: TRACE_X Default: TRACE_X_STEPS
trace_y – What should be plotted on the y-axis? Possibilities: TRACE_Y_FVAL, TRACE_Y_GRADNORM Default: TRACE_Y_FVAl
scale_y – May be logarithmic or linear (‘log10’ or ‘lin’)
offset_y – 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 – maximum value to be plotted on the y-axis, or y-limits
start_indices – list of integers specifying the multistart to be plotted or int specifying up to which start index should be plotted
reference – List of reference points for optimization results, containing at least a function value fval
legends – Labels for line plots, one label per result object
- Returns:
The plot axes.
- Return type:
ax
- pypesto.visualize.optimizer_history_lowlevel(vals: List[ndarray], scale_y: str = 'log10', colors: Tuple[float, float, float, float] | List[Tuple[float, float, float, float]] | None = None, ax: Axes | None = None, size: Tuple = (18.5, 10.5), x_label: str = 'Optimizer steps', y_label: str = 'Objective value', legend_text: str | None = None) Axes [source]
Plot optimizer history using list of numpy arrays.
- Parameters:
vals – list of 2xn-arrays (x_values and y_values of the trace)
scale_y – 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 – Axes object to use.
size – see waterfall
x_label – label for x-axis
y_label – label for y-axis
legend_text – Label for line plots
- Returns:
The plot axes.
- Return type:
ax
- pypesto.visualize.parameter_hist(result: Result, parameter_name: str, bins: int | str = 'auto', ax: matplotlib.Axes | None = None, size: Tuple[float] | None = (18.5, 10.5), color: List[float] | None = None, start_indices: int | List[int] | None = 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:
The plot axes.
- Return type:
ax
- pypesto.visualize.parameters(results: Result | Sequence[Result], ax: Axes | None = None, parameter_indices: str | Sequence[int] = 'free_only', lb: ndarray | List[float] | None = None, ub: ndarray | List[float] | None = None, size: Tuple[float, float] | None = None, reference: List[ReferencePoint] | None = None, colors: Tuple[float, float, float, float] | List[Tuple[float, float, float, float]] | None = None, legends: str | List[str] | None = None, balance_alpha: bool = True, start_indices: int | Iterable[int] | None = None, scale_to_interval: Tuple[float, float] | None = None) 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
scale_to_interval – Tuple of bounds to which to scale all parameter values and bounds, or
None
to use bounds as determined bylb, ub
.
- Returns:
The plot axes.
- Return type:
ax
- pypesto.visualize.parameters_correlation_matrix(result: Result, parameter_indices: str | Sequence[int] = 'free_only', start_indices: int | Iterable[int] | None = None, method: str | Callable = 'pearson', cluster: bool = True, cmap: Colormap | str = 'bwr', return_table: bool = False) Axes [source]
Plot correlation of optimized parameters.
- Parameters:
result – Optimization result obtained by ‘optimize.py’
parameter_indices – List of integers specifying the parameters to be considered.
start_indices – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plotted
method – The method to compute correlation. Allowed are pearson, kendall, spearman or a callable function.
cluster – Whether to cluster the correlation matrix.
cmap – Colormap to use for the heatmap. Defaults to ‘bwr’.
return_table – Whether to return the parameter table additionally for further inspection.
- Returns:
The plot axis.
- Return type:
ax
- pypesto.visualize.parameters_lowlevel(xs: Sequence[ndarray | List[float]], fvals: ndarray | List[float], lb: ndarray | List[float] | None = None, ub: ndarray | List[float] | None = None, x_labels: Iterable[str] | None = None, ax: Axes | None = None, size: Tuple[float, float] | None = None, colors: Sequence[ndarray | List[float]] | None = None, linestyle: str = '-', legend_text: str | None = None, balance_alpha: bool = True) 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.plot_categories_from_inner_result(inner_problem: OptimalScalingProblem, inner_solver: OptimalScalingInnerSolver, results: List[Dict], simulation: List[ndarray], timepoints: List[ndarray], observable_ids: List[str] | None = None, condition_ids: List[str] | None = None, petab_condition_ordering: List[str] | None = None, measurement_df_observable_ordering: List[str] | None = None, axes: Axes | None = None, **kwargs)[source]
Plot the inner solutions.
- Parameters:
inner_problem – The inner problem.
inner_solver – The inner solver.
results – The results from the inner solver.
simulation – The model simulation.
timepoints – The timepoints of the simulation.
kwargs – Additional arguments to pass to the figure.
axes – The optional axes to plot on.
- Returns:
fig – The figure.
axes – The axes.
- pypesto.visualize.plot_categories_from_pypesto_result(pypesto_result: Result, start_index=0, axes: Axes | None = None, **kwargs)[source]
Plot the inner solutions from a pypesto result.
- Parameters:
pypesto_result – The pypesto result.
start_index – The index of the pypesto_result.optimize_result.list to plot.
axes – The optional axes to plot on.
kwargs – Additional arguments to pass to the figure.
- Returns:
fig – The figure.
axes – The axes.
- pypesto.visualize.plot_splines_from_inner_result(inner_problem: SplineInnerProblem, results: List[Dict], observable_ids=None, **kwargs)[source]
Plot the inner solutions.
- Parameters:
inner_problem – The inner problem.
results – The results from the inner solver.
kwargs – Additional arguments to pass to the plotting function.
- Returns:
fig – The figure.
ax – The axes.
- pypesto.visualize.plot_splines_from_pypesto_result(pypesto_result: Result, start_index=0, **kwargs)[source]
Plot the inner solutions from a pypesto result.
- Parameters:
pypesto_result – The pypesto result.
start_index – The index of the pypesto_result.optimize_result.list to plot.
kwargs – Additional arguments to pass to the plotting function.
- Returns:
fig – The figure.
ax – The axes.
- pypesto.visualize.process_offset_y(offset_y: float | None, 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: Result | List[Result], colors=None, legends=None)[source]
Assign colors and legends to a list of results, check user provided lists.
- Parameters:
- 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: Result, confidence_level: float = 0.95, profile_indices: Sequence[int] | None = None, profile_list: int = 0, color: str | tuple = 'C0', show_bounds: bool = False, ax: Axes | None = None) 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: str | None = None, show_bounds: bool = False, lb: float | None = None, ub: float | None = 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: Result | Sequence[Result], ax=None, profile_indices: Sequence[int] | None = None, size: Sequence[float] = (18.5, 6.5), reference: ReferencePoint | Sequence[ReferencePoint] | None = None, colors=None, legends: Sequence[str] | None = None, x_labels: Sequence[str] | None = None, profile_list_ids: 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: str | None = 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: ndarray, components: Sequence[int] = (0, 1), **kwargs)[source]
Plot a scatter plot 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: 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: UmapTypeObject, color_by: Sequence[float] = None, components: Sequence[int] = (0, 1), **kwargs)[source]
See projection_scatter_umap for more documentation.
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: Result, i_chain: int = 0, par_indices: Sequence[int] | None = None, stepsize: int = 1, plot_type: str = 'both', bw_method: str = 'scott', suptitle: str | None = None, size: Tuple[float, float] | None = 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_method ({'scott', 'silverman' | scalar | pair of scalars}) – Kernel bandwidth method.
suptitle – Figure super title.
size – Figure size in inches.
- Returns:
matplotlib-axes
- Return type:
ax
- pypesto.visualize.sampling_fval_traces(result: Result, i_chain: int = 0, full_trace: bool = False, stepsize: int = 1, title: str | None = None, size: Tuple[float, float] | None = None, ax: Axes | None = 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: Result, alpha: Sequence[int] | None = None, step: float = 0.05, show_median: bool = True, title: str | None = None, size: Tuple[float, float] | None = None, ax: Axes | None = None) Axes [source]
Plot MCMC-based parameter credibility intervals.
- 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: Result, i_chain: int = 0, par_indices: Sequence[int] | None = None, full_trace: bool = False, stepsize: int = 1, use_problem_bounds: bool = True, suptitle: str | None = None, size: Tuple[float, float] | None = None, ax: Axes | None = 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: EnsemblePrediction, levels: float | Sequence[float], title: str | None = None, size: Tuple[float, float] | None = None, axes: Axes | None = None, labels: Dict[str, str] | None = None, axis_label_padding: int = 50, groupby: str = 'condition', condition_gap: float = 0.01, condition_ids: Sequence[str] | None = None, output_ids: Sequence[str] | None = None, weighting: bool = False, reverse_opacities: bool = False, average: str = 'median', add_sd: bool = False, measurement_df: DataFrame | None = None) Axes [source]
Visualize prediction trajectory of an EnsemblePrediction.
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:
ensemble_prediction – The ensemble prediction.
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.C.OUTPUT or pypesto.C.CONDITION.
condition_gap – Gap between conditions when groupby == pypesto.C.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.
weighting – Whether weights should be used for trajectory.
reverse_opacities – Whether to reverse the opacities that are assigned to different levels.
average – The ID of the statistic that will be plotted as the average (e.g., MEDIAN or MEAN).
add_sd – Whether to add the standard deviation of the predictions to the plot.
measurement_df – Plot measurement data. NB: This should take the form of a PEtab measurements table, and the observableId column should correspond to the output IDs in the ensemble prediction.
- Returns:
The plot axes.
- Return type:
axes
- pypesto.visualize.sampling_scatter(result: Result, i_chain: int = 0, stepsize: int = 1, suptitle: str | None = None, diag_kind: str = 'kde', size: Tuple[float, float] | None = None, show_bounds: bool = True)[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.
show_bounds – Whether to show, and extend the plot to, the lower and upper bounds.
- Returns:
The plot axes.
- Return type:
ax
- pypesto.visualize.waterfall(results: Result | Sequence[Result], ax: Axes | None = None, size: Tuple[float] | None = (18.5, 10.5), y_limits: Tuple[float] | None = None, scale_y: str | None = 'log10', offset_y: float | None = None, start_indices: Sequence[int] | int | None = None, n_starts_to_zoom: int = 0, reference: Sequence[ReferencePoint] | None = None, colors: Tuple[float, float, float, float] | Sequence[Tuple[float, float, float, float]] | None = None, legends: Sequence[str] | str | None = None, order_by_id: bool = False)[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
n_starts_to_zoom – Number of best multistarts that should be zoomed in. Should be smaller that the total number of multistarts
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
order_by_id – Function values corresponding to the same start ID will be located at the same x-axis position. Only applicable when a list of result objects are provided. Default behavior is to sort the function values of each result independently of other results.
- Returns:
ax – The plot axes.
- Return type:
matplotlib.Axes
- pypesto.visualize.waterfall_lowlevel(fvals, ax: Axes | None = None, size: Tuple[float] | None = (18.5, 10.5), scale_y: str = 'log10', offset_y: float = 0.0, colors: Tuple[float, float, float, float] | Sequence[Tuple[float, float, float, float]] | None = None, legend_text: str | None = None)[source]
Plot waterfall plot using list of function values.
- Parameters:
fvals (numeric list or array) – Including values need to be plotted. None values indicate that the corresponding start index should be skipped.
ax (matplotlib.Axes) – Axes object to use.
size – Figure size (width, height) in inches. Is only applied when no ax object is specified
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
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 – Label for line plots
- Returns:
ax – The plot axes.
- Return type:
matplotlib.Axes