evaluations

This module contains all plots and point estimates that can be used to conduct model evaluation.

respyabc.evaluation.compute_central_credible_interval(history, parameter, interval_type='simulated', alpha=0.05)[source]

Returns credible intervals for the all pyabc runs.

Parameters
  • history (pyabc.smc) – An object created by pyabc.abc.run() or respyabc.respyabc().

  • parameter (str) – Parameter for which the credible interval should be computed.

  • interval_type ({"simulated", "mean"}, optional) – Method that is used to compute the interval ranges. The default is "simulated".

  • alpha (float, optional) – Level of credibility. Must be between zero and one.

Returns

df_ccf – Data frame containing the credibility intervals for all runs.

Return type

pandas.DataFrame

respyabc.evaluation.compute_distribution_bounds(history, parameter, alpha, run)[source]

Returns distribution bounds from pyabc posterior distribution.

Parameters
  • history (pyabc.smc) – An object created by pyabc.abc.run() or respyabc.respyabc().

  • parameter (str) – Parameter for which the credible interval should be computed.

  • alpha (float) – Level of credibility. Must be between zero and one.

  • run (int) – Positive integer determining which pyabc run should be used. If None last run is used.

Returns

  • lower (float) – Lower bound of the interval.

  • upper (float) – Upper bound of the interval.

respyabc.evaluation.compute_point_estimate(history, run=None)[source]

Returns point estimates for the pyabc run.

Parameters
  • history (pyabc.smc) – An object created by pyabc.abc.run() or respyabc.respyabc().

  • run (int, optional) – Positive integer determining which pyabc run should be used. If None last run is used.

Returns

df_stacked_moments – Data frame including the point estimate and its varianc for all parameters.

Return type

pandas.DataFrame

respyabc.evaluation.plot_2d_histogram(history, parameter_names, parameter_true, xmin, xmax, ymin, ymax, numx=200, numy=200, label='true theta', figsize=(10, 8))[source]

Wrapper to plot 2 dimensional kernel density estimates.

Parameters
  • history (pyabc.smc) – An object created by pyabc.abc.run() or respyabc.respyabc().

  • parameter_names (list of str) – Strings including the name of the parameter for which the posterior should be plotted.

  • xmin (float) – Minimum value for axes of first parameter.

  • xmax (float) – Maximum value for axes of first parameter.

  • ymin (float) – Minimum value for axes of second parameter.

  • ymax (float) – Maximum value for axes of second parameter.

  • label (str, optional) – Label for the true value.

  • figsize (tuple, optional) – Tuple of floats that is passed to figsize.

Returns

Return type

Plots for two dimensional kernel density estimates over all populations.

respyabc.evaluation.plot_credible_intervals(history, parameter, interval_type='simulated', alpha=0.05, main_title='Central Credible Intervals', y_label=None)[source]

Plot the credible intervals of the posterior distribution of an pyABC run.

Parameters
  • history (pyabc.smc) – An object created by pyabc.abc.run() or respyabc.respyabc().

  • parameter (str) – String including the name of the parameter for which the posterior should be plotted.

  • interval_type ({"simulated", "mean"}, optional) – Method that is used to compute the interval ranges. The default is "simulated".

  • alpha (float, optional) – Level of credibility. Must be between zero and one.

  • main_title (str, optional) – Main title of the plot.

  • y_label (str or None, default None) – Label of y axis. If None, name of parameter is used.

Returns

Return type

Plot with the central credible intervals of the parameter.

respyabc.evaluation.plot_credible_intervals_pyabc(history, m=0, ts=None, plot_legend=False, par_names=None, levels=None, show_mean=False, show_kde_max=False, show_kde_max_1d=False, size=None, refval=None, refval_color='C1', kde=None, kde_1d=None, arr_ax=None)[source]

Taken from pyABC to adjust legend settings. Plot credible intervals over time.

Parameters
  • history (History) – The history to extract data from.

  • m (int, optional (default = 0)) – The id of the model to plot for.

  • ts (Union[List[int], int], optional (default = all)) – The time points to plot for.

  • par_names (List[str], optional) – The parameter to plot for. If None, then all parameters are used.

  • levels (List[float], optional (default = [0.95])) – Confidence intervals to compute.

  • show_mean (bool, optional (default = False)) – Whether to show the mean apart from the median as well.

  • show_kde_max (bool, optional (default = False)) – Whether to show the one of the sampled points that gives the highest KDE value for the specified KDE. Note: It is not attemtped to find the overall hightest KDE value, but rather the sampled point with the highest value is taken as an approximation (of the MAP-value).

  • show_kde_max_1d (bool, optional (default = False)) – Same as show_kde_max, but here the KDE is applied componentwise.

  • size (tuple of float) – Size of the plot.

  • refval (dict, optional (default = None)) – A dictionary of reference parameter values to plot for each of par_names.

  • refval_color (str, optional) – Color to use for the reference value.

  • kde (Transition, optional (default = MultivariateNormalTransition)) – The KDE to use for show_kde_max.

  • kde_1d (Transition, optional (default = MultivariateNormalTransition)) – The KDE to use for show_kde_max_1d.

  • arr_ax (List, optional) – Array of axes to use. Assumed to be a 1-dimensional list.

Returns

arr_ax

Return type

Array of generated axes.

respyabc.evaluation.plot_history_summary(history, parameter_name, parameter_value, confidence_levels=[0.95, 0.9, 0.5], size=(12, 8))[source]

Wrapper to plot the credible intervals of the posterior distribution, the sample numbers, the epsilons and the acceptance rates of an pyABC run.

Parameters
  • history (pyabc.smc) – An object created by pyabc.abc.run() or respyabc.respyabc().

  • parameter_name (str) – String including the name of the parameter for which the posterior should be plotted.

  • parameter_value (float) – Magnitude of true parameter.

  • confidence_levels (list, optional) – A list of floats indicating the levels for which the credible intervals are computed.

  • size (tuple, optional) – Tuple of floats that is passed to plt.gcf().set_size_inches().

Returns

  • Credible intervals of the posterior distribution,

  • the sample numbers, the epsilons and the acceptance rates

respyabc.evaluation.plot_history_summary_no_kde(history, size=(12, 8))[source]

Wrapper to plot the credible intervals of the posterior distribution, the sample numbers, the epsilons and the acceptance rates of an pyABC run.

Parameters
  • history (pyabc.smc) – An object created by pyabc.abc.run() or respyabc.respyabc().

  • size (tuple, optional) – Tuple of floats that is passed to plt.gcf().set_size_inches().

Returns

  • Credible intervals of the posterior distribution,

  • the sample numbers, the epsilons and the acceptance rates

respyabc.evaluation.plot_kernel_density_posterior(history, parameter, xmin, xmax)[source]

Plot the Kernel densities of the posterior distribution of an pyABC run.

Parameters
  • history (pyabc.smc) – An object created by pyabc.abc.run() or respyabc.respyabc().

  • parameter (str) – String including the name of the parameter for which the posterior should be plotted.

  • xmin (float) – Minimum value for the x-axis’ range.

  • xmax (float) – Maximum value for the x-axis’ range.

Returns

Return type

Plot with posterior distribution of parameter.

respyabc.evaluation.plot_multiple_credible_intervals(history, parameter_names, number_rows, number_columns, confidence_levels=[0.95, 0.9, 0.5], size=(12, 8), legend_location='lower right', delete_axes=None)[source]

Wrapper to plot the credible intervals for multiple parameters.

Parameters
  • history (pyabc.smc) – An object created by pyabc.abc.run() or respyabc.respyabc().

  • parameter_names (list of str) – Strings including the name of the parameter for which the posterior should be plotted.

  • number_rows (int) – Positive integer indicating the number of rows of plots.

  • number_columns (int) – Positive integer indicating the number of plots per column.

  • confidence_levels (list, optional) – A list of floats indicating the levels for which the credible intervals are computed.

  • size (tuple, optional) – Tuple of floats that is passed to plt.gcf().set_size_inches().

  • legend_location (str, optional) – Location of legend in plot. Default is “lower right”

  • delete_axes (list of integers or None) – If list of integers, list specifies position of plot that should be deleted.

Returns

Return type

Credible intervals of the posterior distributions.