Skip to content

Commit

Permalink
Release v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dilpath authored Jan 7, 2025
2 parents be0df58 + 83b68b1 commit 8a460b9
Show file tree
Hide file tree
Showing 85 changed files with 4,134 additions and 3,432 deletions.
28 changes: 28 additions & 0 deletions doc/analysis.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 :mod:`petab_select.analyze` module, which contains some methods to subset and group models,
or compute "weights" (e.g. Akaike weights).

Model hashes
^^^^^^^^^^^^

Model hashes are special objects in the library, that are generated from model-specific information that is unique within a single PEtab Select problem.

This means you can reconstruct the model given some model hash. For example, with this model hash `M1-000`, you can reconstruct the :class:`petab_select.ModelHash` from a string, then reconstruct the :class:`petab_select.Model`.

.. code-block:: language
ModelHash.from_hash("M1-000").get_model(petab_select_problem)
You can use this to get the uncalibrated version of a calibrated model.

.. code-block:: language
model.hash.get_model(petab_select_problem)
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
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
1 change: 1 addition & 0 deletions doc/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
These notebooks need to be run to see the output. Pre-computed output can be viewed in the documentation, at https://petab-select.readthedocs.io/en/stable/examples.html
148 changes: 88 additions & 60 deletions doc/examples/calibrated_models/calibrated_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,114 +2,142 @@
AICc: 37.97523003111246
NLLH: 17.48761501555623
estimated_parameters:
sigma_x2: 4.462298385653177
model_hash: M_0-000
model_id: M_0-000
model_subspace_id: M_0
sigma_x2: 4.462298422134608
iteration: 1
model_hash: M-000
model_id: M-000
model_subspace_id: M
model_subspace_indices:
- 0
- 0
- 0
parameters:
k1: 0
k2: 0
k1: 0.2
k2: 0.1
k3: 0
petab_yaml: petab_problem.yaml
predecessor_model_hash: virtual_initial_model
model_subspace_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
model_hash: M_1-000
model_id: M_1-000
model_subspace_id: M_1
sigma_x2: 0.12242920113658338
iteration: 2
model_hash: M-001
model_id: M-001
model_subspace_id: M
model_subspace_indices:
- 0
- 0
- 0
- 1
parameters:
k1: 0.2
k2: 0.1
k3: estimate
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_0-000
model_subspace_petab_yaml: petab_problem.yaml
predecessor_model_hash: M-000
- criteria:
AICc: -0.27451405630430337
NLLH: -4.137257028152152
AICc: -0.27451438069575573
NLLH: -4.137257190347878
estimated_parameters:
k2: 0.10147827639089564
sigma_x2: 0.12142256779953603
model_hash: M_2-000
model_id: M_2-000
model_subspace_id: M_2
k2: 0.10147824307890803
sigma_x2: 0.12142219599557078
iteration: 2
model_hash: M-010
model_id: M-010
model_subspace_id: M
model_subspace_indices:
- 0
- 0
- 1
- 0
parameters:
k1: 0.2
k2: estimate
k3: 0
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_0-000
model_subspace_petab_yaml: petab_problem.yaml
predecessor_model_hash: M-000
- criteria:
AICc: -0.7053270517931587
NLLH: -4.352663525896579
AICc: -0.7053270766271886
NLLH: -4.352663538313594
estimated_parameters:
k1: 0.20160888007873565
sigma_x2: 0.11713858557052499
model_hash: M_3-000
model_id: M_3-000
model_subspace_id: M_3
k1: 0.20160925279667963
sigma_x2: 0.11714017664827497
iteration: 2
model_hash: M-100
model_id: M-100
model_subspace_id: M
model_subspace_indices:
- 0
- 1
- 0
- 0
parameters:
k1: estimate
k2: 0.1
k3: 0
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_0-000
model_subspace_petab_yaml: petab_problem.yaml
predecessor_model_hash: M-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
model_hash: M_5-000
model_id: M_5-000
model_subspace_id: M_5
sigma_x2: 0.11714017664827497
iteration: 3
model_hash: M-101
model_id: M-101
model_subspace_id: M
model_subspace_indices:
- 1
- 0
- 0
- 0
- 1
parameters:
k1: estimate
k2: 0.1
k3: estimate
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_3-000
model_subspace_petab_yaml: petab_problem.yaml
predecessor_model_hash: M-100
- 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
model_hash: M_6-000
model_id: M_6-000
model_subspace_id: M_6
k1: 0.20924804320838675
k2: 0.0859052351446815
sigma_x2: 0.10386846319370771
iteration: 3
model_hash: M-110
model_id: M-110
model_subspace_id: M
model_subspace_indices:
- 0
- 0
- 1
- 1
- 0
parameters:
k1: estimate
k2: estimate
k3: 0
petab_yaml: petab_problem.yaml
predecessor_model_hash: M_3-000
model_subspace_petab_yaml: petab_problem.yaml
predecessor_model_hash: M-100
- 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-111
model_id: M-111
model_subspace_id: M
model_subspace_indices:
- 1
- 1
- 1
parameters:
k1: estimate
k2: estimate
k3: estimate
model_subspace_petab_yaml: petab_problem.yaml
predecessor_model_hash: M-100
9 changes: 1 addition & 8 deletions doc/examples/calibrated_models/model_space.tsv
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
model_subspace_id petab_yaml k1 k2 k3
M_0 petab_problem.yaml 0 0 0
M_1 petab_problem.yaml 0.2 0.1 estimate
M_2 petab_problem.yaml 0.2 estimate 0
M_3 petab_problem.yaml estimate 0.1 0
M_4 petab_problem.yaml 0.2 estimate estimate
M_5 petab_problem.yaml estimate 0.1 estimate
M_6 petab_problem.yaml estimate estimate 0
M_7 petab_problem.yaml estimate estimate estimate
M petab_problem.yaml 0.2;estimate 0.1;estimate 0
76 changes: 9 additions & 67 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 @@ -33,17 +33,19 @@
"\n",
"from example_cli_famos_helpers import (\n",
" parse_summary_to_progress_list,\n",
" petab_select_problem_yaml, # noqa: F401\n",
")\n",
"\n",
"output_path = Path().resolve() / \"output_famos\"\n",
"output_path_str = str(output_path)\n",
"shutil.rmtree(output_path_str)\n",
"if output_path.exists():\n",
" shutil.rmtree(output_path_str)\n",
"output_path.mkdir(exist_ok=False, parents=True)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "a81560e6",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -108,72 +110,12 @@
},
{
"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": [
"/home/dilan/Documents/future_annex/model_selection/packages/petab_select/petab_select/candidate_space.py:376: RuntimeWarning: Model `model_subspace_1-0001011010010010` has been previously excluded from the candidate space so is skipped here.\n",
" warnings.warn(\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",
"\n",
"petab_select_problem_yaml=$1\n",
"output_path_str=$2\n",
"\n",
Expand Down Expand Up @@ -217,7 +159,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "93caf071",
"metadata": {},
"outputs": [],
Expand All @@ -227,7 +169,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "cb61d0f7",
"metadata": {},
"outputs": [],
Expand Down
Loading

0 comments on commit 8a460b9

Please sign in to comment.