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

Add post--model-selection analysis methods #125

Merged
merged 30 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 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
2ef76da
Update doc/analysis.rst
dilpath Jan 6, 2025
8cb760c
review: update api.rst
dilpath Jan 6, 2025
2b7eefd
warn if no model; clean up analyze.get_best
dilpath Jan 6, 2025
1f40d21
clear outputs
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
11 changes: 11 additions & 0 deletions doc/analysis.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Analysis
========

After using PEtab Select to perform model selection, you may want to operate on all "good" calibrated models.
The PEtab Select Python library provides some methods to help with this. Please request any missing methods.

See the Python API docs for the :class:`petab_select.Models` class, which provides some methods. In particular, :attr:`petab_select.Models.df` can be used
to get a quick overview over all models, as a pandas dataframe.

Additionally, see the Python API docs for the ``petab_select.analysis`` module, which contains some methods to subset and group models,
dilpath marked this conversation as resolved.
Show resolved Hide resolved
or compute "weights" (e.g. Akaike weights).
1 change: 1 addition & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ petab-select Python API
:toctree: generated

petab_select
petab_select.analyze
petab_select.candidate_space
petab_select.constants
petab_select.criteria
Expand Down
70 changes: 49 additions & 21 deletions doc/examples/calibrated_models/calibrated_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
AICc: 37.97523003111246
NLLH: 17.48761501555623
estimated_parameters:
sigma_x2: 4.462298385653177
sigma_x2: 4.462298422134608
iteration: 1
model_hash: M_0-000
model_id: M_0-000
model_subspace_id: M_0
Expand All @@ -17,11 +18,12 @@
petab_yaml: petab_problem.yaml
predecessor_model_hash: virtual_initial_model
- criteria:
AICc: -0.1754060811089051
NLLH: -4.0877030405544525
AICc: -0.17540608110890332
NLLH: -4.087703040554452
estimated_parameters:
k3: 0.0
sigma_x2: 0.12242920113658744
sigma_x2: 0.12242920113658338
iteration: 2
model_hash: M_1-000
model_id: M_1-000
model_subspace_id: M_1
Expand All @@ -36,11 +38,12 @@
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_0-000
- criteria:
AICc: -0.27451405630430337
NLLH: -4.137257028152152
AICc: -0.27451438069575573
NLLH: -4.137257190347878
estimated_parameters:
k2: 0.10147827639089564
sigma_x2: 0.12142256779953603
k2: 0.10147824307890803
sigma_x2: 0.12142219599557078
iteration: 2
model_hash: M_2-000
model_id: M_2-000
model_subspace_id: M_2
Expand All @@ -55,11 +58,12 @@
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_0-000
- criteria:
AICc: -0.7053270517931587
NLLH: -4.352663525896579
AICc: -0.7053270766271886
NLLH: -4.352663538313594
estimated_parameters:
k1: 0.20160888007873565
sigma_x2: 0.11713858557052499
k1: 0.20160925279667963
sigma_x2: 0.11714017664827497
iteration: 2
model_hash: M_3-000
model_id: M_3-000
model_subspace_id: M_3
Expand All @@ -74,12 +78,13 @@
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_0-000
- criteria:
AICc: 9.294672948206841
NLLH: -4.352663525896579
AICc: 9.294672923372811
NLLH: -4.352663538313594
estimated_parameters:
k1: 0.20160888007873565
k1: 0.20160925279667963
k3: 0.0
sigma_x2: 0.11713858557052499
sigma_x2: 0.11714017664827497
iteration: 3
model_hash: M_5-000
model_id: M_5-000
model_subspace_id: M_5
Expand All @@ -94,12 +99,13 @@
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_3-000
- criteria:
AICc: 7.852170288089528
NLLH: -5.073914855955236
AICc: 7.8521704398854
NLLH: -5.0739147800573
estimated_parameters:
k1: 0.20924739987621038
k2: 0.0859065470362628
sigma_x2: 0.1038731029818225
k1: 0.20924804320838675
k2: 0.0859052351446815
sigma_x2: 0.10386846319370771
iteration: 3
model_hash: M_6-000
model_id: M_6-000
model_subspace_id: M_6
Expand All @@ -113,3 +119,25 @@
k3: 0
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_3-000
- criteria:
AICc: 35.94352968170024
NLLH: -6.028235159149878
estimated_parameters:
k1: 0.6228488917665873
k2: 0.020189424009226256
k3: 0.0010850434974038557
sigma_x2: 0.08859278245811462
iteration: 4
model_hash: M_7-000
model_id: M_7-000
model_subspace_id: M_7
model_subspace_indices:
- 0
- 0
- 0
parameters:
k1: estimate
k2: estimate
k3: estimate
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_3-000
71 changes: 6 additions & 65 deletions doc/examples/example_cli_famos.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "1f04dce0",
"metadata": {},
"outputs": [],
Expand All @@ -44,7 +44,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "a81560e6",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -109,69 +109,10 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "bb1a5144",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Executing iteration 1\n",
"Executing iteration 2\n",
"Executing iteration 3\n",
"Executing iteration 4\n",
"Executing iteration 5\n",
"Executing iteration 6\n",
"Executing iteration 7\n",
"Executing iteration 8\n",
"Executing iteration 9\n",
"Executing iteration 10\n",
"Executing iteration 11\n",
"Executing iteration 12\n",
"Executing iteration 13\n",
"Executing iteration 14\n",
"Executing iteration 15\n",
"Executing iteration 16\n",
"Executing iteration 17\n",
"Executing iteration 18\n",
"Executing iteration 19\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"petab_select/petab_select/candidate_space.py:1142: RuntimeWarning: Model `model_subspace_1-0001011010010010` has been previously excluded from the candidate space so is skipped here.\n",
" return_value = self.inner_candidate_space.consider(model)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Executing iteration 20\n",
"Executing iteration 21\n",
"Executing iteration 22\n",
"Executing iteration 23\n",
"Executing iteration 24\n",
"Executing iteration 25\n",
"Executing iteration 26\n",
"Executing iteration 27\n",
"Executing iteration 28\n",
"Executing iteration 29\n",
"Executing iteration 30\n",
"Executing iteration 31\n",
"Executing iteration 32\n",
"Executing iteration 33\n",
"Executing iteration 34\n",
"Executing iteration 35\n",
"Executing iteration 36\n",
"Executing iteration 37\n",
"Model selection has terminated.\n"
]
}
],
"outputs": [],
"source": [
"%%bash -s \"$petab_select_problem_yaml\" \"$output_path_str\"\n",
"petab_select_problem_yaml=$1\n",
Expand Down Expand Up @@ -217,7 +158,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "93caf071",
"metadata": {},
"outputs": [],
Expand All @@ -227,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "cb61d0f7",
"metadata": {},
"outputs": [],
Expand Down
1 change: 1 addition & 0 deletions doc/examples/model_selection/calibrated_M1_4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ criteria:
estimated_parameters:
k2: 0.15
k3: 0.0
iteration: 1
model_hash: M1_4-000
model_id: M1_4-000
model_subspace_id: M1_4
Expand Down
1 change: 1 addition & 0 deletions doc/examples/model_selection/calibrated_M1_7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ estimated_parameters:
k1: 0.25
k2: 0.1
k3: 0.0
iteration: 2
model_hash: M1_7-000
model_id: M1_7-000
model_subspace_id: M1_7
Expand Down
3 changes: 3 additions & 0 deletions doc/examples/model_selection/calibrated_models_1.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- criteria:
AIC: 180
estimated_parameters: {}
iteration: 1
model_hash: M1_0-000
model_id: M1_0-000
model_subspace_id: M1_0
Expand All @@ -17,6 +18,7 @@
- criteria:
AIC: 100
estimated_parameters: {}
iteration: 1
model_hash: M1_1-000
model_id: M1_1-000
model_subspace_id: M1_1
Expand All @@ -33,6 +35,7 @@
- criteria:
AIC: 50
estimated_parameters: {}
iteration: 1
model_hash: M1_2-000
model_id: M1_2-000
model_subspace_id: M1_2
Expand Down
Loading
Loading