pypesto.select
Model Selection
Perform model selection with a PEtab Select problem.
- class pypesto.select.Problem[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.- calibrated_models
Storage for all calibrated models. A dictionary, where keys are model hashes, and values are
petab_select.Model
objects.
- newly_calibrated_models
Storage for models that were calibrated in the previous iteration of model selection. Same type as
calibrated_models
.
- method_caller
A
MethodCaller
, used to run a single iteration of a model selection method.
- model_problem_options
Passed to the constructor of :class:
ModelProblem
.
- petab_select_problem
A PEtab Select problem.
- create_method_caller(**kwargs)[source]
Create a method caller.
kwargs
are passed to theMethodCaller
constructor.- Return type:
MethodCaller
- Returns:
A
MethodCaller
instance.
- multistart_select(predecessor_models=None, **kwargs)[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 “calibrated_models” object (but then the same model could be repeatedly calibrated, if the calibrations start before any have stopped).
kwargs
are passed to theMethodCaller
constructor.- Parameters:
predecessor_models (
Iterable
[Model
]) – The models that will be used as initial models. One “model selection iteration” will be run for each predecessor model.- Return type:
- Returns:
A 2-tuple, with the following values –
the best model; and
the best models (the best model at each iteration).
- select(**kwargs)[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.
kwargs
are passed to theMethodCaller
constructor.- Return type:
- Returns:
A 3-tuple, with the following values –
the best model;
all candidate models in this iteration, as a dict with model hashes as keys and models as values; and
all candidate models from all iterations, as a dict with model hashes as keys and models as values.
- select_to_completion(**kwargs)[source]
Run an algorithm until an exception StopIteration is raised.
kwargs
are passed to theMethodCaller
constructor.An exception
StopIteration
is raised bypypesto.select.method.MethodCaller.__call__()
when no candidate models are found.
- pypesto.select.model_to_pypesto_problem(model, objective=None, x_guesses=None, hierarchical=False)[source]
Create a pyPESTO problem from a PEtab Select model.
- Parameters:
model (
Model
) – The model.objective (
Objective
) – The pyPESTO objective.x_guesses (
Iterable
[dict
[str
,float
]]) – 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.hierarchical (
bool
) – Whether the problem involves hierarchical optimization.
- Return type:
- Returns:
The pyPESTO select problem.