Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create standard/schema for a Model #130

Merged
merged 61 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
85f4cff
closes #120
dilpath Nov 23, 2024
5d8faac
fix tests
dilpath Nov 29, 2024
28da0cd
update notebooks
dilpath Nov 29, 2024
8ef45bb
Merge branch 'develop' into class_models
dilpath Dec 2, 2024
2926e6c
Update petab_select/ui.py
dilpath Dec 2, 2024
b52fa53
Update petab_select/ui.py
dilpath Dec 2, 2024
ffaef40
track iterations; fix `ModelHash.get_model`; add `Model.__repr__`
dilpath Dec 2, 2024
4d8e36f
add analysis module
dilpath Dec 2, 2024
486260b
fixme: use pypesto PR branch
dilpath Dec 2, 2024
e8b8ab9
Merge branch 'develop' into analyze
dilpath Dec 2, 2024
74fed0b
unfix pypesto in tox.ini to use pyproject.toml
dilpath Dec 2, 2024
8e799eb
fix tests
dilpath Dec 3, 2024
7585748
test
dilpath Dec 3, 2024
05d17e8
sort iterations in `group_by_iteration`
dilpath Dec 13, 2024
eaa4796
add `VIRTUAL_INITIAL_MODEL_HASH`
dilpath Dec 13, 2024
2d8017c
method to convert Models to dataframe; update plotting code
dilpath Dec 13, 2024
529c799
update vis example to use iterations
dilpath Dec 13, 2024
7224118
update vis notebook
dilpath Dec 13, 2024
49dc4a9
doc analysis methods briefly
dilpath Dec 13, 2024
3ec430b
typo
dilpath Dec 13, 2024
9432358
move models criterion getter to `Models`; add `Models.values()` for b…
dilpath Dec 13, 2024
53d7afe
update test
dilpath Dec 13, 2024
ee21f64
add Model.hashes
dilpath Dec 14, 2024
74398ae
test case 0009: add caveat
dilpath Dec 14, 2024
fb38d2d
fix notebooks
dilpath Dec 14, 2024
fe48416
update expected test case results
dilpath Dec 14, 2024
1fa6579
start sorting of constants
dilpath Dec 15, 2024
a7a7db6
refactor `Model` with mkstd
dilpath Dec 15, 2024
2e6828c
add some old petab parameter helpers to `Model`; add default_compare
dilpath Dec 15, 2024
f5d0589
remove constraint column (constraints aren't implemented yet)
dilpath Dec 16, 2024
6cad912
update test cases 1-8 expected models
dilpath Dec 16, 2024
c0e61cb
split `ModelBase` into `VirtualModelBase` to make virtual object; cas…
dilpath Dec 16, 2024
5efaf2f
update cli.py
dilpath Dec 16, 2024
bc0b086
update plot.py
dilpath Dec 16, 2024
7cf6a5a
update models.py
dilpath Dec 16, 2024
0df740a
update constants.py
dilpath Dec 16, 2024
6ece3fa
update ui.py
dilpath Dec 16, 2024
5b6ea51
refactor to remove `PetabMixin`
dilpath Dec 16, 2024
b03485d
update model_subspace.py; fix selector sets
dilpath Dec 16, 2024
bb965f8
predecessor_model now always set to virtual or real model; update can…
dilpath Dec 17, 2024
951f169
model subspace: require explicit parameter definitions; implement `ca…
dilpath Dec 17, 2024
8eef832
update famos candidate space
dilpath Dec 17, 2024
3106f16
fix standard type; support resolving relative paths in constructor
dilpath Dec 17, 2024
d69c0ba
fix 0009 expected yaml
dilpath Dec 17, 2024
469a602
test case 0009: update expected.yaml
dilpath Dec 17, 2024
e774b1c
check subclass first
dilpath Dec 17, 2024
bff07c3
dedent
dilpath Dec 17, 2024
7d57c35
Merge branch 'analyze' into mkstd
dilpath Dec 17, 2024
ec5b631
add schema; add to RTD
dilpath Dec 17, 2024
f36d70b
subheadings
dilpath Dec 17, 2024
e91123d
Update petab_select/model_subspace.py
dilpath Dec 18, 2024
09470ae
update test_analyze.py
dilpath Dec 17, 2024
aa2331e
update test_famos.py
dilpath Jan 1, 2025
241706c
review: add link
dilpath Jan 1, 2025
1735098
fix link
dilpath Jan 1, 2025
84d099d
update test_cli.py
dilpath Jan 1, 2025
6419dad
fix link
dilpath Jan 1, 2025
daf876b
fix test_model.py
dilpath Jan 1, 2025
1e01423
temp fix pypesto
dilpath Jan 1, 2025
1ef4dcd
fix link
dilpath Jan 1, 2025
678ae44
Merge branch 'develop' into mkstd
dilpath Jan 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
# html_static_path = ['_static']
html_static_path = ["standard"]
html_logo = "logo/logo-wide.svg"


Expand Down
53 changes: 34 additions & 19 deletions doc/problem_definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Model selection problems for PEtab Select are defined by the following files:
#. a specification of the model space, and
#. (optionally) a specification of the initial candidate model.

The different file formats are described below.
The different file formats are described below. Each file format is a YAML file
and comes with a YAML-formatted JSON schema, such that these files can be
easily worked with independently of the PEtab Select library.

1. Selection problem
--------------------
Expand Down Expand Up @@ -116,28 +118,41 @@ can be specified like
selected model.

Here, the format for a single model is shown. Multiple models can be specified
as a YAML list of the same format. The only required key is the ``petab_yaml``,
as a model requires a PEtab problem. Other keys are required in different
as a YAML list of the same format. Some optional keys are required in different
contexts (for example, model comparison will require ``criteria``).

Brief format description
^^^^^^^^^^^^^^^^^^^^^^^^


.. code-block:: yaml

criteria: # dict[string, float] (optional). Criterion ID => criterion value.
estimated_parameters: # dict[string, float] (optional). Parameter ID => parameter value.
model_hash: # string (optional).
model_id: # string (optional).
model_subspace_id: # string (optional).
model_subspace_indices: # string (optional).
parameters: # dict[string, float] (optional). Parameter ID => parameter value or "estimate".
petab_yaml: # string.
predecessor_model_hash: # string (optional).
model_subspace_id: # str (required).
model_subspace_indices: # list[int] (required).
criteria: # dict[str, float] (optional). Criterion ID => criterion value.
model_hash: # str (optional).
model_subspace_petab_yaml: # str (required).
estimated_parameters: # dict[str, float] (optional). Parameter ID => parameter value.
iteration: # int (optional).
model_id: # str (optional).
parameters: # dict[str, float | int | "estimate"] (required). Parameter ID => parameter value or "estimate".
predecessor_model_hash: # str (optional).

- ``criteria``: The value of the criterion by which model selection was performed, at least. Optionally, other criterion values too.
- ``estimated_parameters``: Parameter estimates, not only of parameters specified to be estimated in a model space file, but also parameters specified to be estimated in the original PEtab problem of the model.
- ``model_hash``: The model hash, generated by the PEtab Select library.
- ``model_id``: The model ID.
- ``model_subspace_id``: Same as in the model space files.
- ``model_subspace_indices``: The indices that locate this model in its model subspace.
- ``parameters``: The parameters from the problem (either values or ``'estimate'``) (a specific combination from a model space file, but uncalibrated).
- ``petab_yaml``: Same as in model space files.
- ``predecessor_model_hash``: The hash of the model that preceded this model during the model selection process.
- ``criteria``: The value of the criterion by which model selection was performed, at least. Optionally, other criterion values too.
- ``model_hash``: The model hash, generated by the PEtab Select library. The format is ``[MODEL_SUBSPACE_ID]-[MODEL_SUBSPACE_INDICES_HASH]``. If all parameters are in the model are defined like ``0;estimate``, then the hash is a string of ``1`` and ``0``, for parameters that are estimated or not, respectively.
- ``model_subspace_petab_yaml``: Same as in model space files (see ``petab_yaml``).
- ``estimated_parameters``: Parameter estimates, including all estimated parameters that are not in the model selection problem; i.e., parameters that are set to be estimated in the model subspace PEtab problem but don't appear in the column header of the model space file.
- ``iteration``: The iteration of model selection in which this model appeared.
- ``model_id``: The model ID.
- ``parameters``: The parameter combination from the model space file that defines this model (either values or ``"estimate"``). Not the calibrated values, which are in ``estimated_parameters``!
- ``predecessor_model_hash``: The hash of the model that preceded this model during the model selection process. Will be ``virtual_initial_model-`` if the model had no predecessor model.

Schema
^^^^^^

The format is provided as `YAML-formatted JSON schema <_static/model.yaml>`_, which enables easy validation with various third-party tools.

.. literalinclude:: standard/model.yaml
dilpath marked this conversation as resolved.
Show resolved Hide resolved
:language: yaml
3 changes: 3 additions & 0 deletions doc/standard/make_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from petab_select.model import ModelStandard

ModelStandard.save_schema("model.yaml")
67 changes: 67 additions & 0 deletions doc/standard/model.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
$defs:
ModelHash:
type: string
description: "A model.\n\nSee :class:`ModelBase` for the standardized attributes.\
\ Additional\nattributes are available in ``Model`` to improve usability.\n\nAttributes:\n\
\ _model_subspace_petab_problem:\n The PEtab problem of the model subspace\
\ of this model.\n If not provided, this is reconstructed from\n :attr:`model_subspace_petab_yaml`."
properties:
model_subspace_id:
title: Model Subspace Id
type: string
model_subspace_indices:
items:
type: integer
title: Model Subspace Indices
type: array
criteria:
additionalProperties:
type: number
title: Criteria
type: object
model_hash:
$ref: '#/$defs/ModelHash'
default: null
model_subspace_petab_yaml:
anyOf:
- format: path
type: string
- type: 'null'
title: Model Subspace Petab Yaml
estimated_parameters:
anyOf:
- additionalProperties:
type: number
type: object
- type: 'null'
default: null
title: Estimated Parameters
iteration:
anyOf:
- type: integer
- type: 'null'
default: null
title: Iteration
model_id:
default: null
title: Model Id
type: string
parameters:
additionalProperties:
anyOf:
- type: number
- type: integer
- const: estimate
type: string
title: Parameters
type: object
predecessor_model_hash:
$ref: '#/$defs/ModelHash'
default: null
required:
- model_subspace_id
- model_subspace_indices
- model_subspace_petab_yaml
- parameters
title: Model
type: object
12 changes: 1 addition & 11 deletions doc/test_suite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,70 +15,60 @@ the model format.
- Method
- Model space files
- Compressed format
- Constraints files
- Predecessor (initial) models files
* - 0001
- (all)
- (only one model)
- 1
-
-
-
* - 0002 [#f1]_
- AIC
- forward
- 1
-
-
-
* - 0003
- BIC
- all
- brute force
- 1
- Yes
-
-
* - 0004
- AICc
- backward
- 1
-
- 1
-
* - 0005
- AIC
- forward
- 1
-
-
- 1
* - 0006
- AIC
- forward
- 1
-
-
-
* - 0007 [#f2]_
- AIC
- forward
- 1
-
-
-
* - 0008 [#f2]_
- AICc
- backward
- 1
-
-
-
* - 0009 [#f3]_
- AICc
- FAMoS
- 1
- Yes
-
- Yes

.. [#f1] Model ``M1_0`` differs from ``M1_1`` in three parameters, but only 1 additional estimated parameter. The effect of this on model selection criteria needs to be clarified. Test case 0006 is a duplicate of 0002 that doesn't have this issue.
Expand Down
Loading
Loading