pypesto.select
Model Selection
Perform model selection with a PEtab Select problem.
- class pypesto.select.ModelProblem[source]
Bases:
objectHandles all required calibration tasks on a model.
Handles the creation, estimation, and evaluation of a model. Here, a model is a PEtab problem that is patched with a dictionary of custom parameter values (which may specify that the parameter should be estimated). Evaluation refers to criterion values such as AIC.
- best_start
The best start from a pyPESTO optimize result.
- criterion
The criterion that should be computed after the model is calibrated.
- minimize_method
The optimization method, which should take a :class:
Problemas its only required positional argument, and return a :class:Resultthat contains an :class:OptimizerResult. Other arguments can be provided as keyword arguments, viaminimize_options.
- minimize_options
Keyword argument options that will be passed on to minimize_method.
- minimize_result
A pyPESTO result with an optimize result.
- model
A PEtab Select model.
- model_id
The ID of the PEtab Select model.
- objective_customizer
A method that takes a
pypesto.objective.AmiciObjectiveas input, and makes changes to the objective in-place.
- postprocessor
A method that takes a
ModelSelectionProblemas input. For example, this can be a function that generates a waterfall plot. This postprocessor is applied at the end of theModelProblem.set_result()method.
- pypesto_problem
The pyPESTO problem for the model.
- valid
If False, the model will not be tested.
- x_guess
A single startpoint, that will be used as one of the startpoints in the multi-start optimization.
- __init__(model, criterion, valid=True, autorun=True, x_guess=None, minimize_options=None, objective_customizer=None, postprocessor=None, model_to_pypesto_problem_method=None, minimize_method=None)[source]
Construct then calibrate a model problem.
See the class documentation for documentation of most parameters.
- Parameters:
autorun (
bool) – IfFalse, the model parameters will not be estimated. Allows users to manually callpypesto.optimize.minimizewith custom options, thenset_result().TODO (constraints)
model (Model)
criterion (Criterion)
valid (bool)
minimize_options (dict)
objective_customizer (Callable[[ObjectiveBase], None] | None)
postprocessor (Callable[[ModelProblem], None] | None)
- class pypesto.select.Problem[source]
Bases:
objectHandles 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
All calibrated models.
- Type:
- newly_calibrated_models
All models that were calibrated in the latest iteration of model selection.
- Type:
- method_caller
Used to run a single iteration of a model selection method.
- Type:
pypesto.select.method.MethodCaller
- model_problem_options
Keyword arguments, passed to the constructor of
ModelProblem.
- petab_select_problem
A PEtab Select problem.
- Type:
- __init__(petab_select_problem, model_postprocessor=None, model_problem_options=None)[source]
- Parameters:
petab_select_problem (Problem)
model_postprocessor (Callable[[ModelProblem], None] | None)
model_problem_options (dict)
- create_method_caller(**kwargs)[source]
Create a method caller.
kwargsare passed to theMethodCallerconstructor.- Return type:
MethodCaller- Returns:
A
MethodCallerinstance.
- 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).
kwargsare passed to theMethodCallerconstructor.- Parameters:
predecessor_models (
Models) – 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.
kwargsare passed to theMethodCallerconstructor.
- select_to_completion(**kwargs)[source]
Perform model selection until the method terminates.
kwargsare passed to theMethodCallerconstructor.- Return type:
- Returns:
All models.
- class pypesto.select.SacessMinimizeMethod[source]
Bases:
objectCreate a minimize method for SaCeSS that adapts to each problem.
When a pyPESTO SaCeSS optimizer is created, it takes the problem dimension as input. Hence, an optimizer needs to be constructed for each problem. Objects of this class act like a minimize method for model selection, but a new problem-specific SaCeSS optimizer will be created every time a model is minimized.
Instance attributes correspond to pyPESTO’s SaCeSS optimizer, and are documented there. Extra keyword arguments supplied to the constructor will be passed on to the constructor of the SaCeSS optimizer, for example, max_walltime_s can be specified in this way. If specified, tmpdir will be treated as a parent directory.
- 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.