petab_select.model_subspace
Functions
|
Decompress parameter values. |
Classes
|
Efficient representation of exponentially large model subspaces. |
- class petab_select.model_subspace.ModelSubspace(model_subspace_id, petab_yaml, parameters, exclusions=None)[source]
Efficient representation of exponentially large model subspaces.
- model_subspace_id
The ID of the model subspace.
- petab_yaml
The location of the PEtab problem YAML file.
- parameters
The key is the ID of the parameter. The value is a list of values that the parameter can take (including ESTIMATE).
- exclusions
Hashes of models that have been previously submitted to a candidate space for consideration (
CandidateSpace.consider()
).
- property can_estimate: List[str]
Parameters that can be estimated, according to the subspace.
Parameters that are estimated as part of the PEtab problem are not considered.
- property can_fix: List[str]
Parameters that can be fixed, according to the subspace.
Parameters that are fixed as part of the PEtab problem are not considered.
- check_compatibility_stepwise_method(candidate_space)[source]
Check whether a candidate space is compatible with this subspace.
Directional methods (e.g. forward, backward) are not supported among different PEtab problems.
- Parameters:
candidate_space (
CandidateSpace
) – The candidate space with a stepwise method.- Return type:
- Returns:
Whether the candidate space is compatible.
- exclude_model(model)[source]
Exclude a model from the model subspace.
Models are excluded in ModelSubspace.indices_to_model, which contains the only call to Model.__init__ in the ModelSubspace class.
- exclude_models(models)[source]
Exclude models from the model subspace.
Models are excluded in
ModelSubspace.indices_to_model()
, which contains the only call toModel.__init__()
in theModelSubspace
class.
- static from_definition(model_subspace_id, definition, parent_path=None)[source]
Create a
ModelSubspace
from a definition.- Parameters:
model_subspace_id (
str
) – The model subspace ID.definition (
Union
[Dict
[str
,str
],Series
]) – A description of the model subspace. Keys are properties of the model subspace, including parameters that can take different values.parent_path (
Union
[str
,Path
]) – Any paths in the definition will be set relative to this path.
- Return type:
- Returns:
The model subspace.
- get_models(estimated_parameters)[source]
Get models in the subspace by estimated parameters.
All models that have the provided
estimated_parameters
are returned.- Parameters:
estimated_parameters (
List
[str
]) –The IDs of parameters that are estimated in the model. All other parameters will be fixed. Note that these parameters are in the subset of PEtab parameters that exist in the model subspace definition. Parameters in the PEtab problem but not the model subspace definition should not be included here.
FIXME(dilpath) TODO support the full set of PEtab parameters? Then would need to turn off estimation for parameters that are not provided in estimated_parameters – maybe unexpected for users.
- Return type:
- Returns:
A list of models.
- indices_to_model(indices)[source]
Get a model from the subspace, by indices of possible parameter values.
Model exclusions are handled here.
- Parameters:
indices (
List
[int
]) – The indices of the lists in the values of theModelSubspace.parameters
dictionary, ordered by the keys of this dictionary.- Return type:
- Returns:
A model with the PEtab problem of this subspace and the parameterization that corresponds to the indices.
None
, if the model is excluded from the subspace.
- property must_estimate: List[str]
Subspace parameters that must be estimated.
Does not include parameters that are estimated in the PEtab parameters table.
- property must_fix: List[str]
Subspace parameters that must be fixed.
Parameters that are fixed as part of the PEtab problem are not considered.
- property parameters_all: Dict[str, float | int | Literal['estimate']]
Get all parameters, including those only in the PEtab problem.
Parameter values in the PEtab problem are overwritten by the model subspace values.
- property petab_parameter_ids_estimated: List[str]
Get the IDs of all estimated parameters.
- Returns:
The parameter IDs.
- property petab_parameter_ids_fixed: List[str]
Get the IDs of all fixed parameters.
- Returns:
The parameter IDs.
- property petab_parameters_singular: Dict[str, float | int | Literal['estimate']]
TODO deprecate and remove?
- search(candidate_space, limit=inf)[source]
Search for candidate models in this model subspace.
Nothing is returned, as the result is managed by the
candidate_space
.- Parameters:
candidate_space (
CandidateSpace
) – The candidate space.limit (
int
) – Limit the number of models.
- send_model_to_candidate_space(model, candidate_space, exclude=False)[source]
Send a model to a candidate space for consideration.
- Parameters:
model (
Model
) – The model.candidate_space (
CandidateSpace
) – The candidate space.exclude (
Optional
[bool
]) – Whether to add the model to the exclusions.
- Return type:
- Returns:
Whether it is OK to send additional models to the candidate space. For example, if len(candidate_space.models) == candidate_space.limit, then no further models should be sent.