petab.v2.problem

PEtab v2 problems.

Classes

Problem([model, condition_df, ...])

PEtab parameter estimation problem as defined by

class petab.v2.problem.Problem(model: Model | None = None, condition_df: DataFrame | None = None, measurement_df: DataFrame | None = None, parameter_df: DataFrame | None = None, visualization_df: DataFrame | None = None, observable_df: DataFrame | None = None, mapping_df: DataFrame | None = None, extensions_config: dict | None = None)[source]

Bases: object

PEtab parameter estimation problem as defined by

  • model

  • condition table

  • measurement table

  • parameter table

  • observables table

  • mapping table

Optionally it may contain visualization tables.

Parameters:
  • condition_df – PEtab condition table

  • measurement_df – PEtab measurement table

  • parameter_df – PEtab parameter table

  • observable_df – PEtab observable table

  • visualization_df – PEtab visualization table

  • mapping_df – PEtab mapping table

  • model – The underlying model

  • extensions_config – Information on the extensions used

create_parameter_df(**kwargs) DataFrame[source]

Create a new PEtab parameter table

See create_parameter_df().

static from_combine(filename: Path | str) Problem[source]

Read PEtab COMBINE archive (http://co.mbine.org/documents/archive).

See also petab.create_combine_archive().

Parameters:

filename – Path to the PEtab-COMBINE archive

Returns:

A petab.Problem instance.

static from_yaml(yaml_config: dict | Path | str) Problem[source]

Factory method to load model and tables as specified by YAML file.

Parameters:

yaml_config – PEtab configuration as dictionary or YAML file name

get_lb(free: bool = True, fixed: bool = True, scaled: bool = False)[source]

Generic function to get lower parameter bounds.

Parameters:
  • free – Whether to return free parameters, i.e. parameters to estimate.

  • fixed – Whether to return fixed parameters, i.e. parameters not to estimate.

  • scaled – Whether to scale the values according to the parameter scale, or return them on linear scale.

Return type:

The lower parameter bounds.

get_observable_ids() list[str][source]

Returns dictionary of observable ids.

get_optimization_parameter_scales() dict[str, str][source]

Return list of optimization parameter scaling strings.

See petab.parameters.get_optimization_parameters().

get_optimization_parameters() list[str][source]

Return list of optimization parameter IDs.

See petab.parameters.get_optimization_parameters().

get_optimization_to_simulation_parameter_mapping(**kwargs)[source]

See petab.parameter_mapping.get_optimization_to_simulation_parameter_mapping(), to which all keyword arguments are forwarded.

static get_problem(problem: str | Path | Problem) Problem[source]

Get a PEtab problem from a file or a problem object.

Parameters:

problem – Path to a PEtab problem file or a PEtab problem object.

Returns:

A PEtab problem object.

get_simulation_conditions_from_measurement_df() DataFrame[source]

See petab.get_simulation_conditions().

get_ub(free: bool = True, fixed: bool = True, scaled: bool = False)[source]

Generic function to get upper parameter bounds.

Parameters:
  • free – Whether to return free parameters, i.e. parameters to estimate.

  • fixed – Whether to return fixed parameters, i.e. parameters not to estimate.

  • scaled – Whether to scale the values according to the parameter scale, or return them on linear scale.

Return type:

The upper parameter bounds.

get_x_ids(free: bool = True, fixed: bool = True)[source]

Generic function to get parameter ids.

Parameters:
  • free – Whether to return free parameters, i.e. parameters to estimate.

  • fixed – Whether to return fixed parameters, i.e. parameters not to estimate.

Return type:

The parameter IDs.

get_x_nominal(free: bool = True, fixed: bool = True, scaled: bool = False)[source]

Generic function to get parameter nominal values.

Parameters:
  • free – Whether to return free parameters, i.e. parameters to estimate.

  • fixed – Whether to return fixed parameters, i.e. parameters not to estimate.

  • scaled – Whether to scale the values according to the parameter scale, or return them on linear scale.

Return type:

The parameter nominal values.

property lb: list

Parameter table lower bounds.

property lb_scaled: list

Parameter table lower bounds with applied parameter scaling

property n_estimated: int

The number of estimated parameters.

property n_measurements: int

Number of measurements.

property n_priors: int

Number of priors.

sample_parameter_startpoints(n_starts: int = 100, **kwargs)[source]

Create 2D array with starting points for optimization

See petab.sample_parameter_startpoints().

sample_parameter_startpoints_dict(n_starts: int = 100) list[dict[str, float]][source]

Create dictionaries with starting points for optimization

See also petab.sample_parameter_startpoints().

Returns:

A list of dictionaries with parameter IDs mapping to samples parameter values.

scale_parameters(x_dict: dict[str, float]) dict[str, float][source]

Scale parameter values.

Parameters:

x_dict – Keys are parameter IDs in the PEtab problem, values are unscaled parameter values.

Return type:

The scaled parameter values.

property ub: list

Parameter table upper bounds

property ub_scaled: list

Parameter table upper bounds with applied parameter scaling

unscale_parameters(x_dict: dict[str, float]) dict[str, float][source]

Unscale parameter values.

Parameters:

x_dict – Keys are parameter IDs in the PEtab problem, values are scaled parameter values.

Return type:

The unscaled parameter values.

validate(validation_tasks: list[ValidationTask] = None) ValidationResultList[source]

Validate the PEtab problem.

Parameters:

validation_tasks – List of validation tasks to run. If None or empty, Problem.validation_tasks are used.

Returns:

A list of validation results.

property x_fixed_ids: list[str]

Parameter table parameter IDs, for fixed parameters.

property x_fixed_indices: list[int]

Parameter table non-estimated parameter indices.

property x_free_ids: list[str]

Parameter table parameter IDs, for free parameters.

property x_free_indices: list[int]

Parameter table estimated parameter indices.

property x_ids: list[str]

Parameter table parameter IDs

property x_nominal: list

Parameter table nominal values

property x_nominal_fixed: list

Parameter table nominal values, for fixed parameters.

property x_nominal_fixed_scaled: list

Parameter table nominal values with applied parameter scaling, for fixed parameters.

property x_nominal_free: list

Parameter table nominal values, for free parameters.

property x_nominal_free_scaled: list

Parameter table nominal values with applied parameter scaling, for free parameters.

property x_nominal_scaled: list

Parameter table nominal values with applied parameter scaling