vivarium-public-health 4.3.1__tar.gz → 4.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/.gitignore +1 -4
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/CHANGELOG.rst +9 -1
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/PKG-INFO +1 -1
- vivarium_public_health-4.3.3/docs/source/api_reference/risks/distributions.rst +1 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/__init__.py +1 -7
- vivarium_public_health-4.3.3/src/vivarium_public_health/_version.py +1 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/population/data_transformations.py +2 -2
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/results/__init__.py +0 -1
- vivarium_public_health-4.3.1/src/vivarium_public_health/exposure/exposure.py → vivarium_public_health-4.3.3/src/vivarium_public_health/risks/base_risk.py +99 -48
- {vivarium_public_health-4.3.1/src/vivarium_public_health/exposure → vivarium_public_health-4.3.3/src/vivarium_public_health/risks}/distributions.py +38 -102
- vivarium_public_health-4.3.3/src/vivarium_public_health/risks/effect.py +533 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/risks/implementations/low_birth_weight_and_short_gestation.py +12 -17
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/treatment/__init__.py +0 -1
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health.egg-info/PKG-INFO +1 -1
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health.egg-info/SOURCES.txt +1 -14
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/mock_artifact.py +0 -26
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/results/test_categorical_risk_observer.py +4 -4
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/risks/test_base_risk.py +11 -46
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/risks/test_data_transformations.py +3 -5
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/risks/test_effect.py +7 -8
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/risks/test_low_birth_weight_and_short_gestation.py +1 -1
- vivarium_public_health-4.3.1/docs/source/api_reference/exposure/data_transformations.rst +0 -1
- vivarium_public_health-4.3.1/docs/source/api_reference/exposure/distributions.rst +0 -1
- vivarium_public_health-4.3.1/docs/source/api_reference/exposure/effect.rst +0 -1
- vivarium_public_health-4.3.1/docs/source/api_reference/exposure/exposure.rst +0 -1
- vivarium_public_health-4.3.1/docs/source/api_reference/exposure/index.rst +0 -11
- vivarium_public_health-4.3.1/docs/source/api_reference/treatment/intervention.rst +0 -1
- vivarium_public_health-4.3.1/src/vivarium_public_health/_version.py +0 -1
- vivarium_public_health-4.3.1/src/vivarium_public_health/exposure/__init__.py +0 -2
- vivarium_public_health-4.3.1/src/vivarium_public_health/exposure/effect.py +0 -356
- vivarium_public_health-4.3.1/src/vivarium_public_health/results/intervention.py +0 -139
- vivarium_public_health-4.3.1/src/vivarium_public_health/risks/base_risk.py +0 -125
- vivarium_public_health-4.3.1/src/vivarium_public_health/risks/data_transformations.py +0 -32
- vivarium_public_health-4.3.1/src/vivarium_public_health/risks/distributions.py +0 -24
- vivarium_public_health-4.3.1/src/vivarium_public_health/risks/effect.py +0 -228
- vivarium_public_health-4.3.1/src/vivarium_public_health/treatment/intervention.py +0 -85
- vivarium_public_health-4.3.1/tests/interventions/test_intervention.py +0 -126
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/.bandit +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/.flake8 +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/.gitattributes +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/.github/CODEOWNERS +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/.github/pull_request_template.md +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/.github/workflows/deploy.yml +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/.pylintrc +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/.readthedocs.yml +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/.zenodo.json +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/CODE_OF_CONDUCT.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/CONTRIBUTING.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/Jenkinsfile +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/LICENSE.txt +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/MANIFEST.in +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/Makefile +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/README.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/Makefile +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/nitpick-exceptions +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/_static/style.css +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/_templates/layout.html +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/disease/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/disease/model.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/disease/models.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/disease/special_disease.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/disease/state.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/disease/transition.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/mslt/delay.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/mslt/disease.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/mslt/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/mslt/intervention.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/mslt/magic_wand_components.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/mslt/observer.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/mslt/population.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/plugins/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/plugins/parser.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/population/add_new_birth_cohorts.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/population/base_population.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/population/data_transformations.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/population/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/population/mortality.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/results/disability.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/results/disease.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/results/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/results/mortality.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/results/observer.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/results/risk.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/results/simple_cause.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/results/stratification.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/risks/base_risk.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/risks/data_transformations.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/risks/effect.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/risks/implementations/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/risks/implementations/low_birth_weight_and_short_gestation.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/risks/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/treatment/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/treatment/magic_wand.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/treatment/scale_up.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/treatment/therapeutic_inertia.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/api_reference/utilities.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/conf.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/tutorials/index.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/docs/source/tutorials/risk_exposure.rst +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/pyproject.toml +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/python_versions.json +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/setup.cfg +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/setup.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/__about__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/disease/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/disease/exceptions.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/disease/model.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/disease/models.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/disease/special_disease.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/disease/state.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/disease/transition.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/mslt/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/mslt/delay.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/mslt/disease.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/mslt/intervention.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/mslt/magic_wand_components.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/mslt/observer.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/mslt/population.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/plugins/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/plugins/parser.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/population/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/population/add_new_birth_cohorts.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/population/base_population.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/population/mortality.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/results/columns.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/results/disability.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/results/disease.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/results/mortality.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/results/observer.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/results/risk.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/results/simple_cause.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/results/stratification.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/risks/__init__.py +0 -0
- {vivarium_public_health-4.3.1/src/vivarium_public_health/exposure → vivarium_public_health-4.3.3/src/vivarium_public_health/risks}/data_transformations.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/risks/implementations/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/treatment/magic_wand.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/treatment/scale_up.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/treatment/therapeutic_inertia.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/utilities.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health.egg-info/dependency_links.txt +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health.egg-info/not-zip-safe +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health.egg-info/requires.txt +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health.egg-info/top_level.txt +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/conftest.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/data/rr_interpolator.csv +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/disease/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/disease/test_disease.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/disease/test_special_disease.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/plugins/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/plugins/test_parser.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/population/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/population/conftest.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/population/test_add_new_birth_cohort.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/population/test_base_population.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/population/test_data_transformations.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/population/test_mortality.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/results/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/results/test_disability.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/results/test_disability_observer.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/results/test_disease_observer.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/results/test_mortality_observer.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/results/test_stratification.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/risks/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/risks/conftest.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/risks/test_distributions.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/test_utilities.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/treatment/__init__.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tests/treatment/test_scale_up.py +0 -0
- {vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/tox.ini +0 -0
@@ -1,4 +1,12 @@
|
|
1
|
-
**4.3.
|
1
|
+
**4.3.3 - 07/30/25**
|
2
|
+
|
3
|
+
- Revert changes from v4.3.0-4.3.2
|
4
|
+
|
5
|
+
**4.3.2 - 07/30/25** (withdrawn)
|
6
|
+
|
7
|
+
- Support RiskEffect backwards compatibility with v4.2.x
|
8
|
+
|
9
|
+
**4.3.1 - 07/30/25** (withdrawn)
|
2
10
|
|
3
11
|
- Bugfix: reference correct entity name in LBWSG get_current_exposure method
|
4
12
|
- Support backwards compatibility with v4.2.x
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: vivarium_public_health
|
3
|
-
Version: 4.3.
|
3
|
+
Version: 4.3.3
|
4
4
|
Summary: Components for modelling diseases, risks, and interventions with ``vivarium``
|
5
5
|
Home-page: https://github.com/ihmeuw/vivarium_public_health
|
6
6
|
Author: The vivarium developers
|
@@ -0,0 +1 @@
|
|
1
|
+
.. automodule:: vivarium_public_health.risks.distributions
|
{vivarium_public_health-4.3.1 → vivarium_public_health-4.3.3}/src/vivarium_public_health/__init__.py
RENAMED
@@ -46,13 +46,7 @@ from vivarium_public_health.risks import (
|
|
46
46
|
Risk,
|
47
47
|
RiskEffect,
|
48
48
|
)
|
49
|
-
from vivarium_public_health.treatment import
|
50
|
-
AbsoluteShift,
|
51
|
-
Intervention,
|
52
|
-
InterventionEffect,
|
53
|
-
LinearScaleUp,
|
54
|
-
TherapeuticInertia,
|
55
|
-
)
|
49
|
+
from vivarium_public_health.treatment import AbsoluteShift, LinearScaleUp, TherapeuticInertia
|
56
50
|
|
57
51
|
__all__ = [
|
58
52
|
__author__,
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "4.3.3"
|
@@ -584,8 +584,8 @@ def rescale_final_age_bin(builder, population_data):
|
|
584
584
|
|
585
585
|
def validate_crude_birth_rate_data(builder, data_year_max):
|
586
586
|
population_config = builder.configuration.population.to_dict()
|
587
|
-
untracking_age = population_config.get("untracking_age")
|
588
|
-
age_end = population_config.get("age_end")
|
587
|
+
untracking_age = population_config.get("untracking_age", None)
|
588
|
+
age_end = population_config.get("age_end", None)
|
589
589
|
if untracking_age and age_end and age_end != untracking_age:
|
590
590
|
raise ValueError(
|
591
591
|
"If you specify an exit age, the initial population age end must be the same "
|
@@ -1,7 +1,6 @@
|
|
1
1
|
from .columns import COLUMNS
|
2
2
|
from .disability import DisabilityObserver
|
3
3
|
from .disease import DiseaseObserver
|
4
|
-
from .intervention import CategoricalInterventionObserver
|
5
4
|
from .mortality import MortalityObserver
|
6
5
|
from .observer import PublicHealthObserver
|
7
6
|
from .risk import CategoricalRiskObserver
|
@@ -1,5 +1,14 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
"""
|
2
|
+
===================
|
3
|
+
Risk Exposure Model
|
4
|
+
===================
|
5
|
+
|
6
|
+
This module contains tools for modeling categorical and continuous risk
|
7
|
+
exposure.
|
8
|
+
|
9
|
+
"""
|
10
|
+
|
11
|
+
from typing import Any
|
3
12
|
|
4
13
|
import pandas as pd
|
5
14
|
from vivarium import Component
|
@@ -10,23 +19,73 @@ from vivarium.framework.randomness import RandomnessStream
|
|
10
19
|
from vivarium.framework.resource import Resource
|
11
20
|
from vivarium.framework.values import Pipeline
|
12
21
|
|
13
|
-
from vivarium_public_health.
|
22
|
+
from vivarium_public_health.risks.data_transformations import get_exposure_post_processor
|
23
|
+
from vivarium_public_health.risks.distributions import (
|
14
24
|
ContinuousDistribution,
|
15
25
|
DichotomousDistribution,
|
16
26
|
EnsembleDistribution,
|
17
|
-
ExposureDistribution,
|
18
27
|
PolytomousDistribution,
|
28
|
+
RiskExposureDistribution,
|
19
29
|
)
|
20
|
-
from vivarium_public_health.risks.data_transformations import get_exposure_post_processor
|
21
30
|
from vivarium_public_health.utilities import EntityString, get_lookup_columns
|
22
31
|
|
23
32
|
|
24
|
-
class
|
25
|
-
"""A
|
33
|
+
class Risk(Component):
|
34
|
+
"""A model for a risk factor defined by either a continuous or a categorical value.
|
35
|
+
|
36
|
+
For example,
|
37
|
+
|
38
|
+
#. high systolic blood pressure as a risk where the SBP is not dichotomized
|
39
|
+
into hypotension and normal but is treated as the actual SBP
|
40
|
+
measurement.
|
41
|
+
#. smoking as two categories: current smoker and non-smoker.
|
42
|
+
|
43
|
+
This component can source data either from builder.data or from parameters
|
44
|
+
supplied in the configuration. If data is derived from the configuration, it
|
45
|
+
must be an integer or float expressing the desired exposure level or a
|
46
|
+
covariate name that is intended to be used as a proxy. For example, for a
|
47
|
+
risk named "risk", the configuration could look like this:
|
48
|
+
|
49
|
+
.. code-block:: yaml
|
50
|
+
|
51
|
+
configuration:
|
52
|
+
risk:
|
53
|
+
exposure: 1.0
|
54
|
+
|
55
|
+
or
|
56
|
+
|
57
|
+
.. code-block:: yaml
|
58
|
+
|
59
|
+
configuration:
|
60
|
+
risk:
|
61
|
+
exposure: proxy_covariate
|
26
62
|
|
27
|
-
|
28
|
-
|
29
|
-
|
63
|
+
For polytomous risks, you can also provide an optional 'rebinned_exposed'
|
64
|
+
block in the configuration to indicate that the risk should be rebinned
|
65
|
+
into a dichotomous risk. That block should contain a list of the categories
|
66
|
+
that should be rebinned into a single exposed category in the resulting
|
67
|
+
dichotomous risk. For example, for a risk named "risk" with categories
|
68
|
+
cat1, cat2, cat3, and cat4 that you wished to rebin into a dichotomous risk
|
69
|
+
with an exposed category containing cat1 and cat2 and an unexposed category
|
70
|
+
containing cat3 and cat4, the configuration could look like this:
|
71
|
+
|
72
|
+
.. code-block:: yaml
|
73
|
+
|
74
|
+
configuration:
|
75
|
+
risk:
|
76
|
+
rebinned_exposed: ['cat1', 'cat2']
|
77
|
+
|
78
|
+
For alternative risk factors, you must provide a 'category_thresholds'
|
79
|
+
block in the in configuration to dictate the thresholds that should be
|
80
|
+
used to bin the continuous distributions. Note that this is mutually
|
81
|
+
exclusive with providing 'rebinned_exposed' categories. For a risk named
|
82
|
+
"risk", the configuration could look like:
|
83
|
+
|
84
|
+
.. code-block:: yaml
|
85
|
+
|
86
|
+
configuration:
|
87
|
+
risk:
|
88
|
+
category_thresholds: [7, 8, 9]
|
30
89
|
|
31
90
|
"""
|
32
91
|
|
@@ -45,18 +104,18 @@ class Exposure(Component, ABC):
|
|
45
104
|
|
46
105
|
@property
|
47
106
|
def name(self) -> str:
|
48
|
-
return self.
|
107
|
+
return self.risk
|
49
108
|
|
50
109
|
@property
|
51
110
|
def configuration_defaults(self) -> dict[str, Any]:
|
52
111
|
return {
|
53
112
|
self.name: {
|
54
113
|
"data_sources": {
|
55
|
-
|
56
|
-
"ensemble_distribution_weights": f"{self.
|
57
|
-
"exposure_standard_deviation": f"{self.
|
114
|
+
"exposure": f"{self.risk}.exposure",
|
115
|
+
"ensemble_distribution_weights": f"{self.risk}.exposure_distribution_weights",
|
116
|
+
"exposure_standard_deviation": f"{self.risk}.exposure_standard_deviation",
|
58
117
|
},
|
59
|
-
"distribution_type": f"{self.
|
118
|
+
"distribution_type": f"{self.risk}.distribution",
|
60
119
|
# rebinned_exposed only used for DichotomousDistribution
|
61
120
|
"rebinned_exposed": [],
|
62
121
|
"category_thresholds": [],
|
@@ -74,42 +133,27 @@ class Exposure(Component, ABC):
|
|
74
133
|
def initialization_requirements(self) -> list[str | Resource]:
|
75
134
|
return [self.randomness]
|
76
135
|
|
77
|
-
@property
|
78
|
-
@abstractmethod
|
79
|
-
def exposure_type(self) -> str:
|
80
|
-
raise NotImplementedError
|
81
|
-
|
82
|
-
@property
|
83
|
-
@abstractmethod
|
84
|
-
def dichotomous_exposure_category_names(self) -> NamedTuple:
|
85
|
-
"""The name of the exposure categories. E.g. "exposed" and "unexposed" or
|
86
|
-
"covered" and "uncovered".
|
87
|
-
|
88
|
-
"""
|
89
|
-
raise NotImplementedError
|
90
|
-
|
91
136
|
#####################
|
92
137
|
# Lifecycle methods #
|
93
138
|
#####################
|
94
139
|
|
95
|
-
def __init__(self,
|
140
|
+
def __init__(self, risk: str):
|
96
141
|
"""
|
97
142
|
|
98
143
|
Parameters
|
99
144
|
----------
|
100
|
-
|
101
|
-
the type and name of a
|
102
|
-
level_type
|
103
|
-
The type of level for the health factor, e.g., "exposure" or "coverage".
|
145
|
+
risk
|
146
|
+
the type and name of a risk, specified as "type.name". Type is singular.
|
104
147
|
"""
|
105
148
|
super().__init__()
|
106
|
-
self.
|
149
|
+
self.risk = EntityString(risk)
|
107
150
|
self.distribution_type = None
|
108
|
-
|
109
|
-
self.
|
110
|
-
self.
|
111
|
-
self.
|
112
|
-
self.
|
151
|
+
|
152
|
+
self.randomness_stream_name = f"initial_{self.risk.name}_propensity"
|
153
|
+
self.propensity_column_name = f"{self.risk.name}_propensity"
|
154
|
+
self.propensity_pipeline_name = f"{self.risk.name}.propensity"
|
155
|
+
self.exposure_pipeline_name = f"{self.risk.name}.exposure"
|
156
|
+
self.exposure_column_name = f"{self.risk.name}_exposure"
|
113
157
|
|
114
158
|
#################
|
115
159
|
# Setup methods #
|
@@ -126,10 +170,17 @@ class Exposure(Component, ABC):
|
|
126
170
|
|
127
171
|
self.randomness = self.get_randomness_stream(builder)
|
128
172
|
self.propensity = self.get_propensity_pipeline(builder)
|
129
|
-
self.exposure = self.
|
130
|
-
|
131
|
-
#
|
132
|
-
|
173
|
+
self.exposure = self.get_exposure_pipeline(builder)
|
174
|
+
|
175
|
+
# We want to set this to True iff there is a non-loglinear risk effect
|
176
|
+
# on this risk instance
|
177
|
+
self.create_exposure_column = bool(
|
178
|
+
[
|
179
|
+
component
|
180
|
+
for component in builder.components.list_components()
|
181
|
+
if component.startswith(f"non_log_linear_risk_effect.{self.risk.name}_on_")
|
182
|
+
]
|
183
|
+
)
|
133
184
|
|
134
185
|
def get_distribution_type(self, builder: Builder) -> str:
|
135
186
|
"""Get the distribution type for the risk from the configuration.
|
@@ -165,7 +216,7 @@ class Exposure(Component, ABC):
|
|
165
216
|
distribution_type = "dichotomous"
|
166
217
|
return distribution_type
|
167
218
|
|
168
|
-
def get_exposure_distribution(self, builder: Builder) ->
|
219
|
+
def get_exposure_distribution(self, builder: Builder) -> RiskExposureDistribution:
|
169
220
|
"""Creates and sets up the exposure distribution component for the Risk
|
170
221
|
based on its distribution type.
|
171
222
|
|
@@ -185,7 +236,7 @@ class Exposure(Component, ABC):
|
|
185
236
|
"""
|
186
237
|
try:
|
187
238
|
exposure_distribution = self.exposure_distributions[self.distribution_type](
|
188
|
-
self, self.distribution_type
|
239
|
+
self.risk, self.distribution_type
|
189
240
|
)
|
190
241
|
except KeyError:
|
191
242
|
raise NotImplementedError(
|
@@ -210,7 +261,7 @@ class Exposure(Component, ABC):
|
|
210
261
|
required_resources=[self.propensity_column_name],
|
211
262
|
)
|
212
263
|
|
213
|
-
def
|
264
|
+
def get_exposure_pipeline(self, builder: Builder) -> Pipeline:
|
214
265
|
required_columns = get_lookup_columns(
|
215
266
|
self.exposure_distribution.lookup_tables.values()
|
216
267
|
)
|
@@ -242,7 +293,7 @@ class Exposure(Component, ABC):
|
|
242
293
|
|
243
294
|
def update_exposure_column(self, index: pd.Index) -> None:
|
244
295
|
if self.create_exposure_column:
|
245
|
-
exposure = pd.Series(self.
|
296
|
+
exposure = pd.Series(self.exposure(index), name=self.exposure_column_name)
|
246
297
|
self.population_view.update(exposure)
|
247
298
|
|
248
299
|
##################################
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"""
|
2
2
|
=================================
|
3
|
-
Exposure Distribution Models
|
3
|
+
Risk Exposure Distribution Models
|
4
4
|
=================================
|
5
5
|
|
6
6
|
This module contains tools for modeling several different risk
|
@@ -8,12 +8,8 @@ exposure distributions.
|
|
8
8
|
|
9
9
|
"""
|
10
10
|
|
11
|
-
from __future__ import annotations
|
12
|
-
|
13
|
-
import warnings
|
14
11
|
from abc import ABC, abstractmethod
|
15
12
|
from collections.abc import Callable
|
16
|
-
from typing import TYPE_CHECKING
|
17
13
|
|
18
14
|
import numpy as np
|
19
15
|
import pandas as pd
|
@@ -28,15 +24,12 @@ from vivarium.framework.values import Pipeline, list_combiner, union_post_proces
|
|
28
24
|
from vivarium_public_health.risks.data_transformations import pivot_categorical
|
29
25
|
from vivarium_public_health.utilities import EntityString, get_lookup_columns
|
30
26
|
|
31
|
-
if TYPE_CHECKING:
|
32
|
-
from vivarium_public_health.exposure import Exposure
|
33
|
-
|
34
27
|
|
35
28
|
class MissingDataError(Exception):
|
36
29
|
pass
|
37
30
|
|
38
31
|
|
39
|
-
class
|
32
|
+
class RiskExposureDistribution(Component, ABC):
|
40
33
|
|
41
34
|
#####################
|
42
35
|
# Lifecycle methods #
|
@@ -44,32 +37,23 @@ class ExposureDistribution(Component, ABC):
|
|
44
37
|
|
45
38
|
def __init__(
|
46
39
|
self,
|
47
|
-
|
40
|
+
risk: EntityString,
|
48
41
|
distribution_type: str,
|
49
42
|
exposure_data: int | float | pd.DataFrame | None = None,
|
50
43
|
) -> None:
|
51
44
|
super().__init__()
|
52
|
-
self.
|
45
|
+
self.risk = risk
|
53
46
|
self.distribution_type = distribution_type
|
54
|
-
if (
|
55
|
-
self.distribution_type != "dichotomous"
|
56
|
-
and self.exposure_component.entity.type == "intervention"
|
57
|
-
):
|
58
|
-
raise NotImplementedError(
|
59
|
-
f"Distribution type {self.distribution_type} is not supported for interventions."
|
60
|
-
)
|
61
47
|
self._exposure_data = exposure_data
|
62
48
|
|
63
|
-
self.parameters_pipeline_name =
|
64
|
-
f"{self.exposure_component.entity}.exposure_parameters"
|
65
|
-
)
|
49
|
+
self.parameters_pipeline_name = f"{self.risk}.exposure_parameters"
|
66
50
|
|
67
51
|
#################
|
68
52
|
# Setup methods #
|
69
53
|
#################
|
70
54
|
|
71
55
|
def get_configuration(self, builder: "Builder") -> LayeredConfigTree | None:
|
72
|
-
return builder.configuration[self.
|
56
|
+
return builder.configuration[self.risk]
|
73
57
|
|
74
58
|
@abstractmethod
|
75
59
|
def build_all_lookup_tables(self, builder: "Builder") -> None:
|
@@ -78,9 +62,7 @@ class ExposureDistribution(Component, ABC):
|
|
78
62
|
def get_exposure_data(self, builder: Builder) -> int | float | pd.DataFrame:
|
79
63
|
if self._exposure_data is not None:
|
80
64
|
return self._exposure_data
|
81
|
-
return self.get_data(
|
82
|
-
builder, self.configuration["data_sources"][self.exposure_component.exposure_type]
|
83
|
-
)
|
65
|
+
return self.get_data(builder, self.configuration["data_sources"]["exposure"])
|
84
66
|
|
85
67
|
# noinspection PyAttributeOutsideInit
|
86
68
|
def setup(self, builder: Builder) -> None:
|
@@ -105,7 +87,7 @@ class ExposureDistribution(Component, ABC):
|
|
105
87
|
raise NotImplementedError
|
106
88
|
|
107
89
|
|
108
|
-
class EnsembleDistribution(
|
90
|
+
class EnsembleDistribution(RiskExposureDistribution):
|
109
91
|
##############
|
110
92
|
# Properties #
|
111
93
|
##############
|
@@ -124,7 +106,7 @@ class EnsembleDistribution(ExposureDistribution):
|
|
124
106
|
|
125
107
|
def __init__(self, risk: EntityString, distribution_type: str = "ensemble") -> None:
|
126
108
|
super().__init__(risk, distribution_type)
|
127
|
-
self._propensity = f"ensemble_propensity_{self.
|
109
|
+
self._propensity = f"ensemble_propensity_{self.risk}"
|
128
110
|
|
129
111
|
#################
|
130
112
|
# Setup methods #
|
@@ -147,11 +129,7 @@ class EnsembleDistribution(ExposureDistribution):
|
|
147
129
|
distributions = list(raw_weights["parameter"].unique())
|
148
130
|
|
149
131
|
raw_weights = pivot_categorical(
|
150
|
-
builder,
|
151
|
-
self.exposure_component.entity,
|
152
|
-
raw_weights,
|
153
|
-
pivot_column="parameter",
|
154
|
-
reset_index=False,
|
132
|
+
builder, self.risk, raw_weights, pivot_column="parameter", reset_index=False
|
155
133
|
)
|
156
134
|
|
157
135
|
weights, parameters = rd.EnsembleDistribution.get_parameters(
|
@@ -223,7 +201,7 @@ class EnsembleDistribution(ExposureDistribution):
|
|
223
201
|
return x
|
224
202
|
|
225
203
|
|
226
|
-
class ContinuousDistribution(
|
204
|
+
class ContinuousDistribution(RiskExposureDistribution):
|
227
205
|
#####################
|
228
206
|
# Lifecycle methods #
|
229
207
|
#####################
|
@@ -283,12 +261,12 @@ class ContinuousDistribution(ExposureDistribution):
|
|
283
261
|
return x
|
284
262
|
|
285
263
|
|
286
|
-
class PolytomousDistribution(
|
264
|
+
class PolytomousDistribution(RiskExposureDistribution):
|
287
265
|
@property
|
288
266
|
def categories(self) -> list[str]:
|
289
|
-
# These need to be sorted so the cumulative sum is in the
|
267
|
+
# These need to be sorted so the cumulative sum is in the ocrrect order of categories
|
290
268
|
# and results are therefore reproducible and correct
|
291
|
-
return sorted(self.lookup_tables[
|
269
|
+
return sorted(self.lookup_tables["exposure"].value_columns)
|
292
270
|
|
293
271
|
#################
|
294
272
|
# Setup methods #
|
@@ -299,11 +277,9 @@ class PolytomousDistribution(ExposureDistribution):
|
|
299
277
|
exposure_value_columns = self.get_exposure_value_columns(exposure_data)
|
300
278
|
|
301
279
|
if isinstance(exposure_data, pd.DataFrame):
|
302
|
-
exposure_data = pivot_categorical(
|
303
|
-
builder, self.exposure_component.entity, exposure_data, "parameter"
|
304
|
-
)
|
280
|
+
exposure_data = pivot_categorical(builder, self.risk, exposure_data, "parameter")
|
305
281
|
|
306
|
-
self.lookup_tables[
|
282
|
+
self.lookup_tables["exposure"] = self.build_lookup_table(
|
307
283
|
builder, exposure_data, exposure_value_columns
|
308
284
|
)
|
309
285
|
|
@@ -317,11 +293,9 @@ class PolytomousDistribution(ExposureDistribution):
|
|
317
293
|
def get_exposure_parameter_pipeline(self, builder: Builder) -> Pipeline:
|
318
294
|
return builder.value.register_value_producer(
|
319
295
|
self.parameters_pipeline_name,
|
320
|
-
source=self.lookup_tables[
|
296
|
+
source=self.lookup_tables["exposure"],
|
321
297
|
component=self,
|
322
|
-
required_resources=get_lookup_columns(
|
323
|
-
[self.lookup_tables[self.exposure_component.exposure_type]]
|
324
|
-
),
|
298
|
+
required_resources=get_lookup_columns([self.lookup_tables["exposure"]]),
|
325
299
|
)
|
326
300
|
|
327
301
|
##################
|
@@ -339,12 +313,12 @@ class PolytomousDistribution(ExposureDistribution):
|
|
339
313
|
).sum(axis=1)
|
340
314
|
return pd.Series(
|
341
315
|
np.array(self.categories)[category_index],
|
342
|
-
name=
|
316
|
+
name=self.risk + ".exposure",
|
343
317
|
index=quantiles.index,
|
344
318
|
)
|
345
319
|
|
346
320
|
|
347
|
-
class DichotomousDistribution(
|
321
|
+
class DichotomousDistribution(RiskExposureDistribution):
|
348
322
|
|
349
323
|
#################
|
350
324
|
# Setup methods #
|
@@ -358,15 +332,11 @@ class DichotomousDistribution(ExposureDistribution):
|
|
358
332
|
any_negatives = (exposure_data[exposure_value_columns] < 0).any().any()
|
359
333
|
any_over_one = (exposure_data[exposure_value_columns] > 1).any().any()
|
360
334
|
if any_negatives or any_over_one:
|
361
|
-
raise ValueError(
|
362
|
-
f"All exposures must be in the range [0, 1] for {self.exposure_component.entity}"
|
363
|
-
)
|
335
|
+
raise ValueError(f"All exposures must be in the range [0, 1] for {self.risk}")
|
364
336
|
elif exposure_data < 0 or exposure_data > 1:
|
365
|
-
raise ValueError(
|
366
|
-
f"Exposure must be in the range [0, 1] for {self.exposure_component.entity}"
|
367
|
-
)
|
337
|
+
raise ValueError(f"Exposure must be in the range [0, 1] for {self.risk}")
|
368
338
|
|
369
|
-
self.lookup_tables[
|
339
|
+
self.lookup_tables["exposure"] = self.build_lookup_table(
|
370
340
|
builder, exposure_data, exposure_value_columns
|
371
341
|
)
|
372
342
|
self.lookup_tables["paf"] = self.build_lookup_table(builder, 0.0)
|
@@ -380,43 +350,20 @@ class DichotomousDistribution(ExposureDistribution):
|
|
380
350
|
# rebin exposure categories
|
381
351
|
self.validate_rebin_source(builder, exposure_data)
|
382
352
|
rebin_exposed_categories = set(self.configuration["rebinned_exposed"])
|
383
|
-
# Check if risk exposure is exposed vs cat1
|
384
|
-
if (
|
385
|
-
"cat1" in exposure_data["parameter"].unique()
|
386
|
-
and self.exposure_component.entity.type == "risk_factor"
|
387
|
-
):
|
388
|
-
warnings.warn(
|
389
|
-
"Using 'cat1' and 'cat2' for dichotomous exposure is deprecated and will be removed in a future release. Use 'exposed' and 'unexposed' instead.",
|
390
|
-
FutureWarning,
|
391
|
-
stacklevel=2,
|
392
|
-
)
|
393
|
-
exposure_data["parameter"] = exposure_data["parameter"].replace(
|
394
|
-
{
|
395
|
-
"cat1": self.exposure_component.dichotomous_exposure_category_names.exposed,
|
396
|
-
"cat2": self.exposure_component.dichotomous_exposure_category_names.unexposed,
|
397
|
-
}
|
398
|
-
)
|
399
353
|
if rebin_exposed_categories:
|
400
|
-
exposure_data = self._rebin_exposure_data(
|
401
|
-
exposure_data,
|
402
|
-
rebin_exposed_categories,
|
403
|
-
self.exposure_component.dichotomous_exposure_category_names.exposed,
|
404
|
-
)
|
354
|
+
exposure_data = self._rebin_exposure_data(exposure_data, rebin_exposed_categories)
|
405
355
|
|
406
|
-
exposure_data = exposure_data[
|
407
|
-
exposure_data["parameter"]
|
408
|
-
== self.exposure_component.dichotomous_exposure_category_names.exposed
|
409
|
-
]
|
356
|
+
exposure_data = exposure_data[exposure_data["parameter"] == "cat1"]
|
410
357
|
return exposure_data.drop(columns="parameter")
|
411
358
|
|
412
359
|
@staticmethod
|
413
360
|
def _rebin_exposure_data(
|
414
|
-
exposure_data: pd.DataFrame, rebin_exposed_categories: set
|
361
|
+
exposure_data: pd.DataFrame, rebin_exposed_categories: set
|
415
362
|
) -> pd.DataFrame:
|
416
363
|
exposure_data = exposure_data[
|
417
364
|
exposure_data["parameter"].isin(rebin_exposed_categories)
|
418
365
|
]
|
419
|
-
exposure_data["parameter"] =
|
366
|
+
exposure_data["parameter"] = "cat1"
|
420
367
|
exposure_data = (
|
421
368
|
exposure_data.groupby(list(exposure_data.columns.difference(["value"])))
|
422
369
|
.sum()
|
@@ -435,7 +382,7 @@ class DichotomousDistribution(ExposureDistribution):
|
|
435
382
|
def setup(self, builder: Builder) -> None:
|
436
383
|
super().setup(builder)
|
437
384
|
self.joint_paf = builder.value.register_value_producer(
|
438
|
-
f"{self.
|
385
|
+
f"{self.risk}.exposure_parameters.paf",
|
439
386
|
source=lambda index: [self.lookup_tables["paf"](index)],
|
440
387
|
component=self,
|
441
388
|
preferred_combiner=list_combiner,
|
@@ -444,12 +391,10 @@ class DichotomousDistribution(ExposureDistribution):
|
|
444
391
|
|
445
392
|
def get_exposure_parameter_pipeline(self, builder: Builder) -> Pipeline:
|
446
393
|
return builder.value.register_value_producer(
|
447
|
-
f"{self.
|
394
|
+
f"{self.risk}.exposure_parameters",
|
448
395
|
source=self.exposure_parameter_source,
|
449
396
|
component=self,
|
450
|
-
required_resources=get_lookup_columns(
|
451
|
-
[self.lookup_tables[self.exposure_component.exposure_type]]
|
452
|
-
),
|
397
|
+
required_resources=get_lookup_columns([self.lookup_tables["exposure"]]),
|
453
398
|
)
|
454
399
|
|
455
400
|
##############
|
@@ -460,31 +405,29 @@ class DichotomousDistribution(ExposureDistribution):
|
|
460
405
|
if not isinstance(data, pd.DataFrame):
|
461
406
|
return
|
462
407
|
|
463
|
-
rebin_exposed_categories = set(
|
464
|
-
builder.configuration[self.exposure_component.entity]["rebinned_exposed"]
|
465
|
-
)
|
408
|
+
rebin_exposed_categories = set(builder.configuration[self.risk]["rebinned_exposed"])
|
466
409
|
|
467
410
|
if (
|
468
411
|
rebin_exposed_categories
|
469
|
-
and builder.configuration[self.
|
412
|
+
and builder.configuration[self.risk]["category_thresholds"]
|
470
413
|
):
|
471
414
|
raise ValueError(
|
472
415
|
f"Rebinning and category thresholds are mutually exclusive. "
|
473
|
-
f"You provided both for {self.
|
416
|
+
f"You provided both for {self.risk.name}."
|
474
417
|
)
|
475
418
|
|
476
419
|
invalid_cats = rebin_exposed_categories.difference(set(data.parameter))
|
477
420
|
if invalid_cats:
|
478
421
|
raise ValueError(
|
479
422
|
f"The following provided categories for the rebinned exposed "
|
480
|
-
f"category of {self.
|
423
|
+
f"category of {self.risk.name} are not found in the exposure data: "
|
481
424
|
f"{invalid_cats}."
|
482
425
|
)
|
483
426
|
|
484
427
|
if rebin_exposed_categories == set(data.parameter):
|
485
428
|
raise ValueError(
|
486
429
|
f"The provided categories for the rebinned exposed category of "
|
487
|
-
f"{self.
|
430
|
+
f"{self.risk.name} comprise all categories for the exposure data. "
|
488
431
|
f"At least one category must be left out of the provided categories "
|
489
432
|
f"to be rebinned into the unexposed category."
|
490
433
|
)
|
@@ -494,9 +437,7 @@ class DichotomousDistribution(ExposureDistribution):
|
|
494
437
|
##################################
|
495
438
|
|
496
439
|
def exposure_parameter_source(self, index: pd.Index) -> pd.Series:
|
497
|
-
base_exposure = self.lookup_tables[
|
498
|
-
index
|
499
|
-
).values
|
440
|
+
base_exposure = self.lookup_tables["exposure"](index).values
|
500
441
|
joint_paf = self.joint_paf(index).values
|
501
442
|
return pd.Series(base_exposure * (1 - joint_paf), index=index, name="values")
|
502
443
|
|
@@ -507,13 +448,8 @@ class DichotomousDistribution(ExposureDistribution):
|
|
507
448
|
def ppf(self, quantiles: pd.Series) -> pd.Series:
|
508
449
|
exposed = quantiles < self.exposure_parameters(quantiles.index)
|
509
450
|
return pd.Series(
|
510
|
-
exposed.replace(
|
511
|
-
|
512
|
-
True: self.exposure_component.dichotomous_exposure_category_names.exposed,
|
513
|
-
False: self.exposure_component.dichotomous_exposure_category_names.unexposed,
|
514
|
-
}
|
515
|
-
),
|
516
|
-
name=f"{self.exposure_component.entity}.{self.exposure_component.exposure_type}",
|
451
|
+
exposed.replace({True: "cat1", False: "cat2"}),
|
452
|
+
name=self.risk + ".exposure",
|
517
453
|
index=quantiles.index,
|
518
454
|
)
|
519
455
|
|