Model Selection

Perform model selection with a PEtab Select problem.

class pypesto.select.Problem(petab_select_problem: petab_select.problem.Problem, model_postprocessor: Optional[Callable[[ModelProblem], None]] = None)[source]

Bases: object

Handles use of a model selection algorithm.

Handles model selection. Usage involves initialisation with a model specifications file, and then calling the select() method to perform model selection with a specified algorithm and criterion.

history

Storage for all calibrated models. A dictionary, where keys are model hashes, and values are petab_select.Model objects.

method_caller

A MethodCaller, used to run a single iteration of a model selection method.

model_postprocessor

A method that is applied to each model after calibration.

petab_select_problem

A PEtab Select problem.

__init__(petab_select_problem: petab_select.problem.Problem, model_postprocessor: Optional[Callable[[ModelProblem], None]] = None)[source]

Initialize self. See help(type(self)) for accurate signature.

create_method_caller(*args, **kwargs)pypesto.select.method.MethodCaller[source]

Create a method caller.

args and kwargs are passed to the MethodCaller constructor.

Returns

A MethodCaller instance.

Return type

MethodCaller

multistart_select(*args, predecessor_models: Optional[Iterable[petab_select.model.Model]] = None, **kwargs)Tuple[petab_select.model.Model, List[petab_select.model.Model]][source]

Run an algorithm multiple times, with different predecessor models.

Note that the same method caller is currently shared between all calls. This may change when parallelization is implemented, but for now ensures that the same model isn’t calibrated twice. Could also be managed by sharing the same “history” object (but then the same model could be repeatedly calibrated, if the calibrations start before any have stopped).

args and kwargs are passed to the MethodCaller constructor.

Parameters

predecessor_models – The models that will be used as initial models. One “model selection iteration” will be run for each predecessor model.

Returns

A 2-tuple, with the following values:

  1. the best model; and

  2. the best models (the best model at each iteration).

Return type

tuple

select(*args, **kwargs)Tuple[petab_select.model.Model, Dict[str, petab_select.model.Model], Dict[str, petab_select.model.Model]][source]

Run a single iteration of a model selection algorithm.

The result is the selected model for the current run, independent of previous selected models.

args and kwargs are passed to the MethodCaller constructor.

Returns

A 3-tuple, with the following values:

  1. the best model;

  2. all candidate models in this iteration, as a dict with model hashes as keys and models as values; and

  3. all candidate models from all iterations, as a dict with model hashes as keys and models as values.

Return type

tuple

select_to_completion(*args, **kwargs)List[petab_select.model.Model][source]

Run an algorithm until an exception StopIteration is raised.

args and kwargs are passed to the MethodCaller constructor.

An exception StopIteration is raised by pypesto.select.method.MethodCaller.__call__ when no candidate models are found.

Returns

The best models (the best model at each iteration).

Return type

list

pypesto.select.model_to_pypesto_problem(model: petab_select.model.Model, objective: Optional[pypesto.objective.function.Objective] = None, x_guesses: Optional[Iterable[Dict[str, float]]] = None)pypesto.problem.Problem[source]

Create a pyPESTO problem from a PEtab Select model.

Parameters
  • model – The model.

  • objective – The pyPESTO objective.

  • x_guesses – Startpoints to be used in the multi-start optimization. For example, this could be the maximum likelihood estimate from another model. Each dictionary has parameter IDs as keys, and parameter values as values. Values in x_guess for parameters that are not estimated will be ignored and replaced with their value from the PEtab Select model, if defined, else their nominal value in the PEtab parameters table.

Returns

The pyPESTO select problem.

Return type

Problem