pypesto.visualize.model_fit

Visualization of the model fit after optimization.

Currently only for PEtab problems.

Functions

time_trajectory_model(result[, problem, ...])

Visualize the time trajectory of the model with given timepoints.

visualize_optimized_model_fit(petab_problem, ...)

Visualize the optimized model fit of a PEtab problem.

pypesto.visualize.model_fit.time_trajectory_model(result, problem=None, timepoints=None, n_timepoints=1000, start_index=0, state_ids=None, state_names=None, observable_ids=None)[source]

Visualize the time trajectory of the model with given timepoints.

It does this by calling the amici plotting routines.

Parameters:
  • result (Union[Result, Sequence[Result]]) – The result object from optimization.

  • problem (Problem) – A pypesto problem. Default is ‘None’ in which case result.problem is used. Needed in case the result is loaded from hdf5.

  • timepoints (Union[ndarray, Sequence[ndarray]]) – Array of timepoints, at which the trajectory will be plotted.

  • n_timepoints (int) – Number of timepoints to be plotted between 0 and last measurement of the model. Only used when timepoints==None.

  • start_index (int) – Index of Optimization run to be plotted. Default is best start.

  • state_ids (Union[str, Sequence[str]]) – Ids of the states to be plotted.

  • state_names (Union[str, Sequence[str]]) – Names of the states to be plotted.

  • observable_ids (Union[str, Sequence[str]]) – Ids of the observables to be plotted.

Return type:

Optional[Axes]

Returns:

axesmatplotlib.axes.Axes object of the plot.

pypesto.visualize.model_fit.visualize_optimized_model_fit(petab_problem, result, pypesto_problem, start_index=0, return_dict=False, unflattened_petab_problem=None, **kwargs)[source]

Visualize the optimized model fit of a PEtab problem.

Function calls the PEtab visualization file of the petab_problem and visualizes the fit of the optimized parameter. Common additional argument is subplot_dir to specify the directory each subplot is saved to. Further keyword arguments are delegated to petab.visualize.plot_with_vis_spec(), see there for more information.

Parameters:
  • petab_problem (Problem) – The petab.Problem that was optimized.

  • result (Union[Result, Sequence[Result]]) – The result object from optimization.

  • start_index (int) – The index of the optimization run in result.optimize_result.list. Ignored if problem_parameters is provided.

  • pypesto_problem (Problem) – The pyPESTO problem.

  • return_dict (bool) – Return plot and simulation results as a dictionary.

  • unflattened_petab_problem (Problem) – If the original PEtab problem is flattened, this can be passed to plot with the original unflattened problem.

  • kwargs – Passed to petab.visualize.plot_problem().

Return type:

Optional[Axes]

Returns:

  • axes (matplotlib.axes.Axes object of the created plot.)

  • None (In case subplots are saved to file)