pypesto.visualize
Visualize
pypesto comes with various visualization routines. To use these, import pypesto.visualize.
- class pypesto.visualize.ReferencePoint[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.
- 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 (list of RGBA) – One for each element in ‘vals’.
- 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 (list of RGBA) – One for each element in ‘vals’.
- pypesto.visualize.create_references(references=None, x=None, fval=None, color=None, legend=None)[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
- Return type:
- Returns:
colors (list of RGBA) – One for each element in ‘vals’.
- pypesto.visualize.delete_nan_inf(fvals, x=None, xdim=1, magnitude_bound=inf)[source]
Delete nan and inf values in fvals.
If parameters ‘x’ are passed, also the corresponding entries are deleted.
- Parameters:
x (
Optional
[Sequence
[Union
[ndarray
,list
[float
]]]]) – array of parametersfvals (
ndarray
) – array of fvalxdim (
Optional
[int
]) – dimension of x, in case x dimension cannot be inferredmagnitude_bound (
Optional
[float
]) – any values with a magnitude (absolute value) larger than the magnitude_bound are also deleted
- Return type:
- Returns:
x – array of parameters without nan or inf
fvals – array of fval without nan or inf
- pypesto.visualize.ensemble_crosstab_scatter_lowlevel(dataset, component_labels=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.
- pypesto.visualize.ensemble_identifiability(ensemble, ax=None, size=(12, 6))[source]
Visualize identifiablity of parameter ensemble.
Plot an overview about how many parameters hit the parameter bounds based on an ensemble of parameters. confidence intervals/credible ranges are computed via the ensemble mean plus/minus 1 standard deviation. This highlevel routine expects an ensemble object as input.
- pypesto.visualize.ensemble_scatter_lowlevel(dataset, ax=None, size=(12, 6), x_label='component 1', y_label='component 2', color_by=None, color_map='viridis', background_color=(0.0, 0.0, 0.0, 1.0), marker_type='.', scatter_size=0.5, invert_scatter_order=False)[source]
Create a scatter plot.
- Parameters:
dataset – array of data points in reduced dimension
size (
tuple
[float
] |None
) – Figure size (width, height) in inches. Is only applied when no ax object is specifiedx_label (
str
) – The x-axis labely_label (
str
) – The y-axis labelcolor_by (
Sequence
[float
]) – A sequence/list of floats, which specify the color in the colormapcolor_map (
str
) – A colormap name known to pyplotbackground_color (
tuple
[float
,float
,float
,float
]) – Background color of the axes object (defaults to black)marker_type (
str
) – Type of plotted markersscatter_size (
float
) – Size of plotted markersinvert_scatter_order (
bool
) – Specifies the order of plotting the scatter points, can be important in case of overplotting
- Returns:
ax (matplotlib.Axes) – The plot axes.
- pypesto.visualize.optimization_run_properties_one_plot(results, properties_to_plot=None, size=(18.5, 10.5), start_indices=None, colors=None, legends=None, plot_type='line')[source]
Plot stats for allproperties specified in properties_to_plot on one plot.
- Parameters:
results (
Result
) – Optimization result obtained by ‘optimize.py’ or list of thoseproperties_to_plot (
Optional
[list
[str
]]) – Optimization run properties that should be plottedsize (
tuple
[float
,float
]) – Figure size (width, height) in inches. Is only applied when no ax object is specifiedstart_indices (
Union
[int
,Iterable
[int
],None
]) – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plottedcolors (
Union
[list
[float
],list
[list
[float
]],None
]) – 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 automaticallylegends (
Union
[str
,list
[str
],None
]) – Labels, one label per optimization propertyplot_type (
str
) – Specifies plot type. Possible values: ‘line’ and ‘hist’
- Return type:
- 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, properties_to_plot=[‘time’, ‘n_grad’], colors=[[.5, .9, .9, .3], [.2, .1, .9, .5]])
- pypesto.visualize.optimization_run_properties_per_multistart(results, properties_to_plot=None, size=(18.5, 10.5), start_indices=None, colors=None, legends=None, plot_type='line')[source]
One plot per optimization property in properties_to_plot.
- Parameters:
results (
Union
[Result
,Sequence
[Result
]]) – Optimization result obtained by ‘optimize.py’ or list of thoseproperties_to_plot (
Optional
[list
[str
]]) – Optimization run properties that should be plottedsize (
tuple
[float
,float
]) – Figure size (width, height) in inches. Is only applied when no ax object is specifiedstart_indices (
Union
[int
,Iterable
[int
],None
]) – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plottedcolors (
Union
[list
[float
],list
[list
[float
]],None
]) – 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 automaticallylegends (
Union
[str
,list
[str
],None
]) – Labels for line plots, one label per result objectplot_type (
str
) – Specifies plot type. Possible values: ‘line’ and ‘hist’
- Return type:
- 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, opt_run_property, axes=None, size=(18.5, 10.5), start_indices=None, colors=None, legends=None, plot_type='line')[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 (
str
) – optimization run property to plot. One of the ‘time’, ‘n_fval’, ‘n_grad’, ‘n_hess’, ‘n_res’, ‘n_sres’results (
Union
[Result
,Sequence
[Result
]]) – Optimization result obtained by ‘optimize.py’ or list of thosesize (
tuple
[float
,float
]) – Figure size (width, height) in inches. Is only applied when no ax object is specifiedstart_indices (
Union
[int
,Iterable
[int
],None
]) – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plottedcolors (
Union
[list
[float
],list
[list
[float
]],None
]) – 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 automaticallylegends (
Union
[str
,list
[str
],None
]) – Labels for line plots, one label per result objectplot_type (
str
) – Specifies plot type. Possible values: ‘line’, ‘hist’, ‘both’
- Return type:
- Returns:
axes – The plot axes.
- pypesto.visualize.optimization_scatter(result, parameter_indices='free_only', start_indices=None, diag_kind='kde', suptitle=None, size=None, show_bounds=False)[source]
Plot a scatter plot of all pairs of parameters for the given starts.
- Parameters:
result (
Result
) – Optimization result obtained by ‘optimize.py’.parameter_indices (
Union
[str
,Sequence
[int
]]) – List of integers specifying the parameters to be considered.start_indices (
Union
[int
,Iterable
[int
],None
]) – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plotted.diag_kind (
str
) – Visualization mode for marginal densities {‘auto’, ‘hist’, ‘kde’, None}.suptitle (
str
) – Title of the plot.show_bounds (
bool
) – Whether to show the parameter bounds.
- Returns:
ax – The plot axis.
- pypesto.visualize.optimizer_convergence(result, ax=None, xscale='symlog', yscale='log', size=(18.5, 10.5))[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:
- Return type:
- Returns:
ax (matplotlib.Axes) – The plot 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 (
Union
[Result
,list
[Result
]]) – Optimization result obtained by ‘optimize.py’ or list of thosesize (tuple, optional) – Figure size (width, height) in inches. Is only applied when no ax object is specified
trace_x (
str
) – What should be plotted on the x-axis? Possibilities: TRACE_X Default: TRACE_X_STEPStrace_y (
str
) – What should be plotted on the y-axis? Possibilities: TRACE_Y_FVAL, TRACE_Y_GRADNORM Default: TRACE_Y_FVAlscale_y (
str
) – May be logarithmic or linear (‘log10’ or ‘lin’)offset_y (
Optional
[float
]) – Offset for the y-axis-values, as these are plotted on a log10-scale Will be computed automatically if necessarycolors (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 (
Union
[float
,list
[float
],ndarray
,None
]) – maximum value to be plotted on the y-axis, or y-limitsstart_indices (
Union
[int
,list
[int
],None
]) – list of integers specifying the multistart to be plotted or int specifying up to which start index should be plottedreference (
Union
[ReferencePoint
,dict
,list
[ReferencePoint
],list
[dict
],None
]) – List of reference points for optimization results, containing at least a function value fvallegends (
Union
[str
,list
[str
],None
]) – Labels for line plots, one label per result object
- Return type:
- Returns:
ax – The plot 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
[ndarray
]) – list of 2xn-arrays (x_values and y_values of the trace)scale_y (
str
) – 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
size (
tuple
) – see waterfallx_label (
str
) – label for x-axisy_label (
str
) – label for y-axis
- Return type:
- Returns:
ax – The plot axes.
- pypesto.visualize.parameter_hist(result, parameter_name, bins='auto', ax=None, size=(18.5, 10.5), color=None, start_indices=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, ax=None, parameter_indices='free_only', lb=None, ub=None, size=None, reference=None, colors=None, legends=None, balance_alpha=True, start_indices=None, scale_to_interval=None, plot_inner_parameters=True)[source]
Plot parameter values.
- Parameters:
results (
Union
[Result
,Sequence
[Result
]]) – Optimization result obtained by ‘optimize.py’ or list of thoseparameter_indices (
Union
[str
,Sequence
[int
]]) – 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 (
Union
[ndarray
,list
[float
],None
]) – If not None, override result.problem.lb, problem.problem.ub. Dimension either result.problem.dim or result.problem.dim_full.ub (
Union
[ndarray
,list
[float
],None
]) – If not None, override result.problem.lb, problem.problem.ub. Dimension either result.problem.dim or result.problem.dim_full.size (
Optional
[tuple
[float
,float
]]) – Figure size (width, height) in inches. Is only applied when no ax object is specifiedreference (
Optional
[list
[ReferencePoint
]]) – List of reference points for optimization results, containing at least a function value fvalcolors (
Union
[tuple
[float
,float
,float
,float
],list
[tuple
[float
,float
,float
,float
]],None
]) – list of RGBA colors, or single RGBA color If not set, clustering is done and colors are assigned automaticallylegends (
Union
[str
,list
[str
],None
]) – Labels for line plots, one label per result objectbalance_alpha (
bool
) – Flag indicating whether alpha for large clusters should be reduced to avoid overplotting (default: True)start_indices (
Union
[int
,Iterable
[int
],None
]) – list of integers specifying the multistarts to be plotted or int specifying up to which start index should be plottedscale_to_interval (
Optional
[tuple
[float
,float
]]) – Tuple of bounds to which to scale all parameter values and bounds, orNone
to use bounds as determined bylb, ub
.plot_inner_parameters (
bool
) – Flag indicating whether to plot inner parameters (default: True).
- Return type:
- Returns:
ax – The plot axes.
- pypesto.visualize.parameters_correlation_matrix(result, parameter_indices='free_only', start_indices=None, method='pearson', cluster=True, cmap='bwr', return_table=False)[source]
Plot correlation of optimized parameters.
- Parameters:
result (
Result
) – Optimization result obtained by ‘optimize.py’parameter_indices (
Union
[str
,Sequence
[int
]]) – List of integers specifying the parameters to be considered.start_indices (
Union
[int
,Iterable
[int
],None
]) – List of integers specifying the multistarts to be plotted or int specifying up to which start index should be plottedmethod (
Union
[str
,Callable
]) – The method to compute correlation. Allowed are pearson, kendall, spearman or a callable function.cluster (
bool
) – Whether to cluster the correlation matrix.cmap (
Union
[Colormap
,str
]) – Colormap to use for the heatmap. Defaults to ‘bwr’.return_table (
bool
) – Whether to return the parameter table additionally for further inspection.
- Return type:
- Returns:
ax – The plot axis.
- pypesto.visualize.parameters_lowlevel(xs, fvals, lb=None, ub=None, x_labels=None, ax=None, size=None, colors=None, linestyle='-', legend_text=None, balance_alpha=True)[source]
Plot parameters plot using list of parameters.
- Parameters:
xs (
ndarray
) – Including optimized parameters for each start that did not result in an infinite fval. Shape: (n_starts_successful, dim).fvals (
ndarray
) – Function values. Needed to assign cluster colors.lb (
Union
[ndarray
,list
[float
],None
]) – The lower and upper bounds.ub (
Union
[ndarray
,list
[float
],None
]) – The lower and upper bounds.x_labels (
Optional
[Iterable
[str
]]) – Labels to be used for the parameters.colors (
Optional
[Sequence
[Union
[ndarray
,list
[float
]]]]) – One for each element in ‘fvals’.linestyle (
str
) – linestyle argument for parameter plotbalance_alpha (
bool
) – Flag indicating whether alpha for large clusters should be reduced to avoid overplotting (default: True)
- Return type:
- Returns:
ax – The plot axes.
- pypesto.visualize.plot_categories_from_inner_result(inner_problem, inner_solver, results, simulation, timepoints, observable_ids=None, condition_ids=None, petab_condition_ordering=None, measurement_df_observable_ordering=None, axes=None, **kwargs)[source]
Plot the inner solutions.
- Parameters:
inner_problem (
OrdinalProblem
) – The inner problem.inner_solver (
OrdinalInnerSolver
) – The inner solver.timepoints (
list
[ndarray
]) – The timepoints of the simulation.kwargs – Additional arguments to pass to the figure.
- Returns:
fig – The figure.
axes – The axes.
- pypesto.visualize.plot_categories_from_pypesto_result(pypesto_result, start_index=0, axes=None, **kwargs)[source]
Plot the inner solutions from a pypesto result.
- pypesto.visualize.plot_splines_from_inner_result(inner_problem, inner_solver, results, sim, observable_ids=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.
sim – The simulated model output.
observable_ids – The ids of the observables.
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, start_index=0, **kwargs)[source]
Plot the inner solutions from a pypesto result.
- Parameters:
pypesto_result (
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, scale_y, min_val)[source]
Compute offset for y-axis, depend on user settings.
- Parameters:
- Return type:
- Returns:
offset_y (float) – value for offsetting the later plotted values, in order to ensure positivity if a semilog-plot is used
- pypesto.visualize.process_result_list(results, 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 (matplotlib.Axes, optional) – Axes object to use.
- pypesto.visualize.profile_cis(result, confidence_level=0.95, profile_indices=None, profile_list=0, color='C0', show_bounds=False, ax=None)[source]
Plot approximate confidence intervals based on profiles.
- Parameters:
result (
Result
) – The result object after profiling.confidence_level (
float
) – 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 (
Sequence
[int
]) – 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 (
int
) – Index of the profile list to be used.show_bounds (
bool
) – Whether to show, and extend the plot to, the lower and upper bounds.ax (
Axes
) – Axes object to use. Default: Create a new one.
- Return type:
- pypesto.visualize.profile_lowlevel(fvals, ax=None, size=(18.5, 6.5), color=None, legend_text=None, show_bounds=False, lb=None, ub=None)[source]
Lowlevel routine for plotting one profile, working with a numpy array only.
- Parameters:
size (
tuple
[float
,float
]) – 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 (
bool
) – Whether to show, and extend the plot to, the lower and upper bounds.lb (
float
) – Lower bound.ub (
float
) – Upper bound.
- Return type:
- Returns:
The plot axes.
- pypesto.visualize.profiles(results, ax=None, profile_indices=None, size=(18.5, 6.5), reference=None, colors=None, legends=None, x_labels=None, profile_list_ids=0, ratio_min=0.0, show_bounds=False)[source]
Plot classical 1D profile plot.
Using the posterior, e.g. Gaussian like profile.
- Parameters:
results (
Union
[Result
,Sequence
[Result
]]) – List of or single pypesto.Result after profiling.ax – List of axes objects to use.
profile_indices (
Sequence
[int
]) – List of integer values specifying which profiles should be plotted.size (
tuple
[float
,float
]) – Figure size (width, height) in inches. Is only applied when no ax object is specified.reference (
Union
[ReferencePoint
,Sequence
[ReferencePoint
]]) – List of reference points for optimization results, containing at least a function value fval.colors – List of colors, or single color.
legends (
Sequence
[str
]) – Labels for line plots, one label per result object.x_labels (
Sequence
[str
]) – Labels for parameter value axes (e.g. parameter names).profile_list_ids (
Union
[int
,Sequence
[int
]]) – Index or list of indices of the profile lists to visualize.ratio_min (
float
) – Minimum ratio below which to cut off.show_bounds (
bool
) – Whether to show, and extend the plot to, the lower and upper bounds.
- Return type:
- Returns:
ax – The plot axes.
- pypesto.visualize.profiles_lowlevel(fvals, ax=None, size=(18.5, 6.5), color=None, legend_text=None, x_labels=None, show_bounds=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:
size (
tuple
[float
,float
]) – 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 (
bool
) – Whether to show, and extend the plot to, the lower and upper bounds.
- Return type:
- Returns:
The plot axes.
- pypesto.visualize.projection_scatter_pca(pca_coordinates, components=(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:
- Returns:
axs – Either one axes object, or a dictionary of plot axes (depending on the number of coordinates passed)
- pypesto.visualize.projection_scatter_umap(umap_coordinates, components=(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:
- Returns:
axs – Either one axes object, or a dictionary of plot axes (depending on the number of coordinates passed)
- pypesto.visualize.projection_scatter_umap_original(umap_object, color_by=None, components=(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 (
None
) – umap object (returned as second output by get_umap_representation) to be shown as scatter plotcolor_by (
Sequence
[float
]) – A sequence/list of floats, which specify the color in the colormapcomponents (
Sequence
[int
]) – Components to be plotted (corresponds to columns of umap_coordinates)
- Returns:
ax (matplotlib.Axes) – The plot axes.
- pypesto.visualize.sampling_1d_marginals(result, i_chain=0, par_indices=None, stepsize=1, plot_type='both', bw_method='scott', suptitle=None, size=None)[source]
Plot marginals.
- Parameters:
result (
Result
) – The pyPESTO result object with filled sample result.i_chain (
int
) – 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 (
int
) – 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 (
str
) – Figure super title.
- Returns:
ax – matplotlib-axes
- pypesto.visualize.sampling_fval_traces(result, i_chain=0, full_trace=False, stepsize=1, title=None, size=None, ax=None)[source]
Plot log-posterior (=function value) over iterations.
- Parameters:
result (
Result
) – The pyPESTO result object with filled sample result.i_chain (
int
) – Which chain to plot. Default: First chain.full_trace (
bool
) – Plot the full trace including warm up. Default: False.stepsize (
int
) – Only one in stepsize values is plotted.title (
str
) – Axes title.size (ndarray) – Figure size in inches.
ax (
Axes
) – Axes object to use.
- Returns:
ax – The plot axes.
- pypesto.visualize.sampling_parameter_cis(result, alpha=None, step=0.05, show_median=True, title=None, size=None, ax=None)[source]
Plot MCMC-based parameter credibility intervals.
- Parameters:
result (
Result
) – The pyPESTO result object with filled sample result.alpha (
Sequence
[int
]) – List of lower tail probabilities, defaults to 95% interval.step (
float
) – Height of boxes for projectile plot, defaults to 0.05.show_median (
bool
) – Plot the median of the MCMC chain. Default: True.title (
str
) – Axes title.size (ndarray) – Figure size in inches.
ax (
Axes
) – Axes object to use.
- Return type:
- Returns:
ax – The plot axes.
- pypesto.visualize.sampling_parameter_traces(result, i_chain=0, par_indices=None, full_trace=False, stepsize=1, use_problem_bounds=True, suptitle=None, size=None, ax=None)[source]
Plot parameter values over iterations.
- Parameters:
result (
Result
) – The pyPESTO result object with filled sample result.i_chain (
int
) – 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 (
bool
) – Plot the full trace including warm up. Default: False.stepsize (
int
) – Only one in stepsize values is plotted.use_problem_bounds (
bool
) – Defines if the y-limits shall be the lower and upper bounds of parameter estimation problem.suptitle (
str
) – Figure suptitle.ax (
Axes
) – Axes object to use.
- Returns:
ax – The plot axes.
- pypesto.visualize.sampling_prediction_trajectories(ensemble_prediction, levels, title=None, size=None, axes=None, labels=None, axis_label_padding=50, groupby='condition', condition_gap=0.01, condition_ids=None, output_ids=None, weighting=False, reverse_opacities=False, average='median', add_sd=False, measurement_df=None)[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 (
EnsemblePrediction
) – The ensemble prediction.levels (
Union
[float
,Sequence
[float
]]) – 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 (
str
) – Axes title.size (ndarray) – Figure size in inches.
axes (
Axes
) – Axes object to use.labels (
dict
[str
,str
]) – Keys should be ensemble output IDs, values should be the desired label for that output. Defaults to output IDs.axis_label_padding (
int
) – Pixels between axis labels and plots.groupby (
str
) – Group plots by pypesto.C.OUTPUT or pypesto.C.CONDITION.condition_gap (
float
) – Gap between conditions when groupby == pypesto.C.CONDITION.condition_ids (
Sequence
[str
]) – If provided, only data for the provided condition IDs will be plotted.output_ids (
Sequence
[str
]) – If provided, only data for the provided output IDs will be plotted.weighting (
bool
) – Whether weights should be used for trajectory.reverse_opacities (
bool
) – Whether to reverse the opacities that are assigned to different levels.average (
str
) – The ID of the statistic that will be plotted as the average (e.g., MEDIAN or MEAN).add_sd (
bool
) – Whether to add the standard deviation of the predictions to the plot.measurement_df (
DataFrame
) – 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.
- Return type:
- Returns:
axes – The plot axes.
- pypesto.visualize.sampling_scatter(result, i_chain=0, stepsize=1, suptitle=None, diag_kind='kde', size=None, show_bounds=True)[source]
Parameter scatter plot.
- Parameters:
result (
Result
) – The pyPESTO result object with filled sample result.i_chain (
int
) – Which chain to plot. Default: First chain.stepsize (
int
) – Only one in stepsize values is plotted.suptitle (
str
) – Figure super title.diag_kind (
str
) – Visualization mode for marginal densities {‘auto’, ‘hist’, ‘kde’, None}show_bounds (
bool
) – Whether to show, and extend the plot to, the lower and upper bounds.
- Returns:
ax – The plot axes.
- pypesto.visualize.waterfall(results, ax=None, size=(18.5, 10.5), y_limits=None, scale_y='log10', offset_y=None, start_indices=None, n_starts_to_zoom=0, reference=None, colors=None, legends=None, order_by_id=False)[source]
Plot waterfall plot.
- Parameters:
results (
Union
[Result
,Sequence
[Result
]]) – Optimization result obtained by ‘optimize.py’ or list of thoseax (matplotlib.Axes, optional) – Axes object to use.
size (
Optional
[tuple
[float
,float
]]) – Figure size (width, height) in inches. Is only applied when no ax object is specifiedy_limits (float or ndarray, optional) – Maximum value to be plotted on the y-axis, or y-limits
scale_y (
Optional
[str
]) – May be logarithmic or linear (‘log10’ or ‘lin’)offset_y (
Optional
[float
]) – Offset for the y-axis, if it is supposed to be in log10-scalestart_indices (
Union
[Sequence
[int
],int
,None
]) – Integers specifying the multistart to be plotted or int specifying up to which start index should be plottedn_starts_to_zoom (
int
) – Number of best multistarts that should be zoomed in. Should be smaller that the total number of multistartsreference (
Optional
[Sequence
[ReferencePoint
]]) – Reference points for optimization results, containing at least a function value fvalcolors (
Union
[tuple
[float
,float
,float
,float
],Sequence
[tuple
[float
,float
,float
,float
]],None
]) – Colors or single color for plotting. If not set, clustering is done and colors are assigned automaticallylegends (
Union
[Sequence
[str
],str
,None
]) – Labels for line plots, one label per result objectorder_by_id (
bool
) – 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 (matplotlib.Axes) – The plot axes.
- pypesto.visualize.waterfall_lowlevel(fvals, ax=None, size=(18.5, 10.5), scale_y='log10', offset_y=0.0, 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. None values indicate that the corresponding start index should be skipped.
ax (matplotlib.Axes) – Axes object to use.
size (
Optional
[tuple
[float
]]) – Figure size (width, height) in inches. Is only applied when no ax object is specifiedscale_y (str, optional) – May be logarithmic or linear (‘log10’ or ‘lin’)
offset_y (
float
) – offset for the y-axis, if it is supposed to be in log10-scalecolors (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
- Returns:
ax (matplotlib.Axes) – The plot axes.