bella-companion 0.0.47__tar.gz → 0.1.1__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.
Files changed (127) hide show
  1. {bella_companion-0.0.47 → bella_companion-0.1.1}/PKG-INFO +8 -5
  2. {bella_companion-0.0.47 → bella_companion-0.1.1}/pyproject.toml +12 -14
  3. bella_companion-0.1.1/src/bella_companion/.DS_Store +0 -0
  4. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/eucovid/beast_configs/GLM.xml +28 -18
  5. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/eucovid/beast_configs/MLP.xml +3 -4
  6. bella_companion-0.1.1/src/bella_companion/eucovid/run_beast.py +36 -0
  7. bella_companion-0.1.1/src/bella_companion/features.py +13 -0
  8. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/figures/epi_multitype.py +5 -5
  9. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/figures/fbd_2traits.py +5 -5
  10. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/scenarios/epi_multitype.py +1 -1
  11. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/scenarios/epi_skyline.py +1 -1
  12. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/scenarios/fbd_2traits.py +1 -1
  13. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/scenarios/fbd_no_traits.py +1 -1
  14. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/scenarios/scenario.py +1 -1
  15. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/utils/__init__.py +4 -4
  16. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/utils/beast.py +2 -2
  17. bella_companion-0.1.1/src/bella_companion/utils/explain/__init__.py +7 -0
  18. {bella_companion-0.0.47/bella_companion/simulations/figures → bella_companion-0.1.1/src/bella_companion/utils}/explain/pdp.py +61 -18
  19. bella_companion-0.1.1/src/bella_companion/utils/explain/shap.py +104 -0
  20. bella_companion-0.1.1/src/bella_companion/utils/explain/typeguards.py +20 -0
  21. bella_companion-0.0.47/bella_companion/__pycache__/__init__.cpython-310.pyc +0 -0
  22. bella_companion-0.0.47/bella_companion/__pycache__/cli.cpython-310.pyc +0 -0
  23. bella_companion-0.0.47/bella_companion/eucovid/__pycache__/__init__.cpython-310.pyc +0 -0
  24. bella_companion-0.0.47/bella_companion/eucovid/__pycache__/run_beast.cpython-310.pyc +0 -0
  25. bella_companion-0.0.47/bella_companion/eucovid/beast_configs/Nonparametric.xml +0 -399
  26. bella_companion-0.0.47/bella_companion/eucovid/data/case_data.tsv +0 -346
  27. bella_companion-0.0.47/bella_companion/eucovid/data/change_dates.tsv +0 -8
  28. bella_companion-0.0.47/bella_companion/eucovid/data/osi.tsv +0 -376
  29. bella_companion-0.0.47/bella_companion/eucovid/data/predictors/all/closedborders_7e_nt.tsv +0 -35
  30. bella_companion-0.0.47/bella_companion/eucovid/data/predictors/all/dist_7e_ls.tsv +0 -35
  31. bella_companion-0.0.47/bella_companion/eucovid/data/predictors/all/flight_7e_ls.tsv +0 -35
  32. bella_companion-0.0.47/bella_companion/eucovid/data/predictors/all/flight_pop_x_7e_ls.tsv +0 -35
  33. bella_companion-0.0.47/bella_companion/eucovid/data/predictors/all/osi_x_7e_ls.tsv +0 -35
  34. bella_companion-0.0.47/bella_companion/eucovid/data/predictors/all/osi_y_7e_ls.tsv +0 -35
  35. bella_companion-0.0.47/bella_companion/eucovid/data/predictors/all/pop_x_7e_ls.tsv +0 -35
  36. bella_companion-0.0.47/bella_companion/eucovid/data/predictors/all/pop_y_7e_ls.tsv +0 -35
  37. bella_companion-0.0.47/bella_companion/eucovid/data/predictors/all/sharedborders_7e_nt.tsv +0 -35
  38. bella_companion-0.0.47/bella_companion/eucovid/data/predictors/changetimes_all_7e.tsv +0 -6
  39. bella_companion-0.0.47/bella_companion/eucovid/run_beast.py +0 -118
  40. bella_companion-0.0.47/bella_companion/platyrrhine/__pycache__/__init__.cpython-310.pyc +0 -0
  41. bella_companion-0.0.47/bella_companion/platyrrhine/__pycache__/results.cpython-310.pyc +0 -0
  42. bella_companion-0.0.47/bella_companion/platyrrhine/__pycache__/run_beast.cpython-310.pyc +0 -0
  43. bella_companion-0.0.47/bella_companion/platyrrhine/__pycache__/summarize.cpython-310.pyc +0 -0
  44. bella_companion-0.0.47/bella_companion/platyrrhine/__pycache__/summarize_logs.cpython-310.pyc +0 -0
  45. bella_companion-0.0.47/bella_companion/simulations/__pycache__/__init__.cpython-310.pyc +0 -0
  46. bella_companion-0.0.47/bella_companion/simulations/__pycache__/features.cpython-310.pyc +0 -0
  47. bella_companion-0.0.47/bella_companion/simulations/__pycache__/generate_data.cpython-310.pyc +0 -0
  48. bella_companion-0.0.47/bella_companion/simulations/__pycache__/generate_figures.cpython-310.pyc +0 -0
  49. bella_companion-0.0.47/bella_companion/simulations/__pycache__/metrics.cpython-310.pyc +0 -0
  50. bella_companion-0.0.47/bella_companion/simulations/__pycache__/run_beast.cpython-310.pyc +0 -0
  51. bella_companion-0.0.47/bella_companion/simulations/__pycache__/summarize.cpython-310.pyc +0 -0
  52. bella_companion-0.0.47/bella_companion/simulations/__pycache__/summarize_logs.cpython-310.pyc +0 -0
  53. bella_companion-0.0.47/bella_companion/simulations/features.py +0 -7
  54. bella_companion-0.0.47/bella_companion/simulations/figures/__pycache__/__init__.cpython-310.pyc +0 -0
  55. bella_companion-0.0.47/bella_companion/simulations/figures/__pycache__/epi_multitype.cpython-310.pyc +0 -0
  56. bella_companion-0.0.47/bella_companion/simulations/figures/__pycache__/epi_skyline.cpython-310.pyc +0 -0
  57. bella_companion-0.0.47/bella_companion/simulations/figures/__pycache__/fbd_2traits.cpython-310.pyc +0 -0
  58. bella_companion-0.0.47/bella_companion/simulations/figures/__pycache__/fbd_no_traits.cpython-310.pyc +0 -0
  59. bella_companion-0.0.47/bella_companion/simulations/figures/__pycache__/scenarios.cpython-310.pyc +0 -0
  60. bella_companion-0.0.47/bella_companion/simulations/figures/__pycache__/utils.cpython-310.pyc +0 -0
  61. bella_companion-0.0.47/bella_companion/simulations/figures/explain/__init__.py +0 -6
  62. bella_companion-0.0.47/bella_companion/simulations/figures/explain/__pycache__/__init__.cpython-310.pyc +0 -0
  63. bella_companion-0.0.47/bella_companion/simulations/figures/explain/__pycache__/pdp.cpython-310.pyc +0 -0
  64. bella_companion-0.0.47/bella_companion/simulations/figures/explain/__pycache__/shap.cpython-310.pyc +0 -0
  65. bella_companion-0.0.47/bella_companion/simulations/figures/explain/shap.py +0 -62
  66. bella_companion-0.0.47/bella_companion/simulations/scenarios/__pycache__/__init__.cpython-310.pyc +0 -0
  67. bella_companion-0.0.47/bella_companion/simulations/scenarios/__pycache__/common.cpython-310.pyc +0 -0
  68. bella_companion-0.0.47/bella_companion/simulations/scenarios/__pycache__/epi_multitype.cpython-310.pyc +0 -0
  69. bella_companion-0.0.47/bella_companion/simulations/scenarios/__pycache__/epi_skyline.cpython-310.pyc +0 -0
  70. bella_companion-0.0.47/bella_companion/simulations/scenarios/__pycache__/fbd_2traits.cpython-310.pyc +0 -0
  71. bella_companion-0.0.47/bella_companion/simulations/scenarios/__pycache__/fbd_no_traits.cpython-310.pyc +0 -0
  72. bella_companion-0.0.47/bella_companion/simulations/scenarios/__pycache__/scenario.cpython-310.pyc +0 -0
  73. bella_companion-0.0.47/bella_companion/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  74. bella_companion-0.0.47/bella_companion/utils/__pycache__/beast.cpython-310.pyc +0 -0
  75. bella_companion-0.0.47/bella_companion/utils/__pycache__/explain.cpython-310.pyc +0 -0
  76. bella_companion-0.0.47/bella_companion/utils/__pycache__/slurm.cpython-310.pyc +0 -0
  77. bella_companion-0.0.47/bella_companion/utils/explain.py +0 -45
  78. bella_companion-0.0.47/bella_companion.egg-info/PKG-INFO +0 -12
  79. bella_companion-0.0.47/bella_companion.egg-info/SOURCES.txt +0 -119
  80. bella_companion-0.0.47/bella_companion.egg-info/dependency_links.txt +0 -1
  81. bella_companion-0.0.47/bella_companion.egg-info/entry_points.txt +0 -2
  82. bella_companion-0.0.47/bella_companion.egg-info/requires.txt +0 -6
  83. bella_companion-0.0.47/bella_companion.egg-info/top_level.txt +0 -1
  84. bella_companion-0.0.47/setup.cfg +0 -4
  85. {bella_companion-0.0.47 → bella_companion-0.1.1}/README.md +0 -0
  86. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/BELLA.jar +0 -0
  87. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/__init__.py +0 -0
  88. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/cli.py +0 -0
  89. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/eucovid/__init__.py +0 -0
  90. /bella_companion-0.0.47/bella_companion/eucovid/data/predictors/changetimes_flights_4e.tsv → /bella_companion-0.1.1/src/bella_companion/eucovid/data/changetimes.csv +0 -0
  91. /bella_companion-0.0.47/bella_companion/eucovid/data/predictors/flight_pop_x_4e_ls.tsv → /bella_companion-0.1.1/src/bella_companion/eucovid/data/flights.csv +0 -0
  92. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/eucovid/data/msa.fasta +0 -0
  93. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/platyrrhine/__init__.py +0 -0
  94. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/platyrrhine/beast_config.xml +0 -0
  95. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/platyrrhine/data/change_times.csv +0 -0
  96. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/platyrrhine/data/traits.csv +0 -0
  97. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/platyrrhine/data/trees.nwk +0 -0
  98. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/platyrrhine/results.py +0 -0
  99. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/platyrrhine/run_beast.py +0 -0
  100. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/platyrrhine/summarize.py +0 -0
  101. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/__init__.py +0 -0
  102. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/epi-multitype/GLM.xml +0 -0
  103. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/epi-multitype/MLP.xml +0 -0
  104. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/epi-multitype/Nonparametric.xml +0 -0
  105. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/epi-skyline/GLM.xml +0 -0
  106. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/epi-skyline/MLP.xml +0 -0
  107. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/epi-skyline/Nonparametric.xml +0 -0
  108. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/fbd-2traits/GLM.xml +0 -0
  109. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/fbd-2traits/MLP.xml +0 -0
  110. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/fbd-2traits/Nonparametric.xml +0 -0
  111. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/fbd-no-traits/GLM.xml +0 -0
  112. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/fbd-no-traits/MLP.xml +0 -0
  113. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/beast_configs/fbd-no-traits/Nonparametric.xml +0 -0
  114. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/figures/__init__.py +0 -0
  115. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/figures/epi_skyline.py +0 -0
  116. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/figures/fbd_no_traits.py +0 -0
  117. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/figures/scenarios.py +0 -0
  118. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/figures/utils.py +0 -0
  119. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/generate_data.py +0 -0
  120. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/generate_figures.py +0 -0
  121. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/metrics.py +0 -0
  122. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/run_beast.py +0 -0
  123. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/scenarios/__init__.py +0 -0
  124. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/scenarios/common.py +0 -0
  125. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/simulations/summarize.py +0 -0
  126. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/utils/slurm.py +0 -0
  127. {bella_companion-0.0.47 → bella_companion-0.1.1/src}/bella_companion/version.xml +0 -0
@@ -1,12 +1,15 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.3
2
2
  Name: bella-companion
3
- Version: 0.0.47
3
+ Version: 0.1.1
4
4
  Summary: Bayesian Evolutionary Layered Learning Architectures (BELLA) companion
5
- Requires-Python: >=3.10
6
- Description-Content-Type: text/markdown
5
+ Author: gabriele-marino
6
+ Author-email: gabriele-marino <gabmarino.8601@gmail.com>
7
7
  Requires-Dist: arviz>=0.22.0
8
- Requires-Dist: bella-lumiere>=0.0.14
8
+ Requires-Dist: bella-lumiere>=0.1.0
9
9
  Requires-Dist: dotenv>=0.9.9
10
10
  Requires-Dist: phylogenie>=3.1.4
11
11
  Requires-Dist: poetry>=2.2.1
12
12
  Requires-Dist: seaborn>=0.13.2
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+
@@ -1,18 +1,28 @@
1
1
  [project]
2
2
  name = "bella-companion"
3
- version = "0.0.47"
3
+ version = "0.1.1"
4
4
  description = "Bayesian Evolutionary Layered Learning Architectures (BELLA) companion"
5
5
  readme = "README.md"
6
+ authors = [
7
+ { name = "gabriele-marino", email = "gabmarino.8601@gmail.com" }
8
+ ]
6
9
  requires-python = ">=3.10"
7
10
  dependencies = [
8
11
  "arviz>=0.22.0",
9
- "bella-lumiere>=0.0.14",
12
+ "bella-lumiere>=0.1.0",
10
13
  "dotenv>=0.9.9",
11
14
  "phylogenie>=3.1.4",
12
15
  "poetry>=2.2.1",
13
16
  "seaborn>=0.13.2",
14
17
  ]
15
18
 
19
+ [project.scripts]
20
+ bella = "bella_companion.cli:main"
21
+
22
+ [build-system]
23
+ requires = ["uv_build>=0.9.5,<0.10.0"]
24
+ build-backend = "uv_build"
25
+
16
26
  [dependency-groups]
17
27
  dev = [
18
28
  "joblib-stubs>=1.5.2.0.20250831",
@@ -22,15 +32,3 @@ dev = [
22
32
  [tool.pyright]
23
33
  typeCheckingMode = "strict"
24
34
 
25
- [project.scripts]
26
- bella = "bella_companion.cli:main"
27
-
28
- [build-system]
29
- requires = ["setuptools>=42"]
30
- build-backend = "setuptools.build_meta"
31
-
32
- [tool.setuptools]
33
- packages = ["bella_companion"]
34
-
35
- [tool.setuptools.package-data]
36
- bella_companion = ["**/*"]
@@ -48,7 +48,7 @@
48
48
  <populationModel spec="ConstantPopulation" popSize="0.1"/>
49
49
  </stateNode>
50
50
  <stateNode id="Re" spec="RealParameter" value="1.0 1.1 1.2 1.3 1.4 1.01 1.1 1.2 1.3 1.4"/>
51
- <stateNode id="samplingProportion" spec="RealParameter" value="1.11E-5 1.2E-5 1.3E-5 1.4E-5 1.5E-5 1.1E-5 1.2E-5 1.3E-5 1.4E-5 1.5E-5 0.0 0.0 0.0 0.0 0.0"/>
51
+ <stateNode id="samplingProportion" spec="RealParameter" value="1.1E-4 1.2E-4 1.3E-4 1.4E-4 1.5E-4 1.11E-4 1.2E-4 1.3E-4 1.4E-4 1.5E-4 0.0 0.0 0.0 0.0 0.0"/>
52
52
  <stateNode id="migrationRateW" spec="RealParameter" value="0"/>
53
53
  <stateNode id="migrationRateScaler" spec="RealParameter" value="0.1"/>
54
54
  <stateNode id="processLength" spec="RealParameter" value="10.0"/>
@@ -76,9 +76,7 @@
76
76
  <becomeUninfectiousRate spec="SkylineVectorParameter" skylineValues="36.5" typeSet="@typeSet"/>
77
77
  <migrationRate id="migrationRateSP" spec="SkylineMatrixParameter" timesAreAges="true" processLength="@processLength" typeSet="@typeSet">
78
78
  <skylineValues spec="glmprior.util.GLMLogLinear" coefficients="@migrationRateW" scaleFactor="@migrationRateScaler" transform="false">
79
- <plate var="predictorFile" range="$(predictorFiles)">
80
- <predictor spec="RealParameterFromXSV" fileName="$(predictorFile)"/>
81
- </plate>
79
+ <predictor spec="RealParameterFromXSV" fileName="$(flightsPredictorFile)"/>
82
80
  <indicators spec="BooleanParameter" value="1"/>
83
81
  </skylineValues>
84
82
  <changeTimes spec="RealParameterFromXSV" fileName="$(changeTimesFile)"/>
@@ -94,26 +92,37 @@
94
92
  <distribution spec="SmartZeroExcludingPrior" x="@Re">
95
93
  <LogNormal name="distr" M="0.8" S="0.5"/>
96
94
  </distribution>
97
- <distribution spec="SmartZeroExcludingPrior" x="@samplingProportion" classesToExclude="1.2E-5 1.3E-5 1.4E-5 1.5E-5">
98
- <Uniform name="distr" lower="0" upper="0.15"/>
95
+
96
+ <!-- Sampling proportion in China -->
97
+ <distribution spec="SmartZeroExcludingPrior" x="@samplingProportionValues" classesToExclude="1.1E-4 1.2E-4 1.3E-4 1.4E-4 1.5E-4">
98
+ <Uniform name="distr" upper="0.024714828897338403"/>
99
+ </distribution>
100
+ <!-- Sampling proportion in China -->
101
+ <distribution spec="SmartZeroExcludingPrior" x="@samplingProportionValues" classesToExclude="1.11E-4 1.2E-4 1.3E-4 1.4E-4 1.5E-4">
102
+ <Uniform name="distr" upper="$1.8682742128337982e-4"/>
99
103
  </distribution>
100
- <distribution spec="SmartZeroExcludingPrior" x="@samplingProportion" classesToExclude="1.1E-5 1.3E-5 1.4E-5 1.5E-5">
101
- <Uniform name="distr" lower="0" upper="0.093"/>
104
+ <!-- Sampling proportion in France -->
105
+ <distribution spec="SmartZeroExcludingPrior" x="@samplingProportionValues" classesToExclude="1.1E-4 1.11E-4 1.3E-4 1.4E-4 1.5E-4">
106
+ <Uniform name="distr" upper="0.09217877094972067"/>
102
107
  </distribution>
103
- <distribution spec="SmartZeroExcludingPrior" x="@samplingProportion" classesToExclude="1.1E-5 1.2E-5 1.4E-5 1.5E-5">
104
- <Uniform name="distr" lower="0" upper="0.10"/>
108
+ <!-- Sampling proportion in Germany -->
109
+ <distribution spec="SmartZeroExcludingPrior" x="@samplingProportionValues" classesToExclude="1.1E-4 1.11E-4 1.2E-4 1.4E-4 1.5E-4">
110
+ <Uniform name="distr" upper="0.01770956316410862"/>
105
111
  </distribution>
106
- <distribution spec="SmartZeroExcludingPrior" x="@samplingProportion" classesToExclude="1.1E-5 1.2E-5 1.3E-5 1.5E-5">
107
- <Uniform name="distr" lower="0" upper="0.005"/>
112
+ <!-- Sampling proportion in Germany -->
113
+ <distribution spec="SmartZeroExcludingPrior" x="@samplingProportionValues" classesToExclude="1.1E-4 1.11E-4 1.2E-4 1.3E-4 1.5E-4">
114
+ <Uniform name="distr" upper="0.002209756926738059"/>
108
115
  </distribution>
109
- <distribution spec="SmartZeroExcludingPrior" x="@samplingProportion" classesToExclude="1.1E-5 1.2E-5 1.3E-5 1.4E-5">
110
- <Uniform name="distr" lower="0" upper="0.057"/>
116
+ <!-- Sampling proportion in EU -->
117
+ <distribution spec="SmartZeroExcludingPrior" x="@samplingProportionValues" classesToExclude="1.1E-4 1.11E-4 1.2E-4 1.3E-4 1.4E-4">
118
+ <Uniform name="distr" lower="0" upper="0.012770137524557957"/>
111
119
  </distribution>
120
+
112
121
  <prior name="distribution" x="@migrationRateW">
113
122
  <Normal name="distr" mean="0.0" sigma="1.0"/>
114
123
  </prior>
115
124
  <prior name="distribution" x="@migrationRateScaler">
116
- <LogNormal name="distr" M="0.0" S="0.8"/>
125
+ <LogNormal name="distr" M="0.0" S="1"/>
117
126
  </prior>
118
127
  <prior name="distribution" x="@gammaShape">
119
128
  <Exponential name="distr" mean="0.5"/>
@@ -136,14 +145,15 @@
136
145
  <operator spec="BactrianScaleOperator" parameter="@processLength" scaleFactor="0.25" weight="3.0"/>
137
146
  <operator spec="SmartScaleOperator" parameter="@Re" scaleFactor="0.25" weight="10.0"/>
138
147
  <operator spec="SmartScaleOperator" parameter="@samplingProportion" weight="3.0"/>
139
- <operator spec="BactrianRandomWalkOperator" parameter="@migrationRateW" weight="5.0" scaleFactor="0.1"/>
140
- <operator spec="AdaptableVarianceMultivariateNormalOperator" weight="5.0" coefficient="1.0" scaleFactor="0.5" beta="0.05" initial="800" burnin="400" every="1">
148
+ <operator spec="BactrianScaleOperator" parameter="@migrationRateScaler" scaleFactor="0.25" weight="3.0"/>
149
+ <operator spec="BactrianRandomWalkOperator" parameter="@migrationRateW" scaleFactor="0.1" weight="5.0"/>
150
+ <operator spec="AdaptableVarianceMultivariateNormalOperator" weight="5.0" scaleFactor="0.5" coefficient="1.0" beta="0.05" initial="800" burnin="400" every="1">
141
151
  <transformations spec="Transform$NoTransform" f="@migrationRateW"/>
142
152
  </operator>
143
153
  <operator spec="BactrianScaleOperator" parameter="@gammaShape" weight="1.0"/>
144
154
  <operator spec="BactrianScaleOperator" parameter="@kappa" weight="1.0"/>
145
155
 
146
- <logger spec="Logger" fileName="MCMC.log" logEvery="1000" model="@posterior" sanitiseHeaders="true" sort="smart">
156
+ <logger spec="Logger" fileName="MCMC.log" logEvery="1000" model="@posterior">
147
157
  <log idref="posterior"/>
148
158
  <log idref="likelihood"/>
149
159
  <log idref="prior"/>
@@ -77,12 +77,11 @@
77
77
  <becomeUninfectiousRate spec="SkylineVectorParameter" skylineValues="36.5" typeSet="@typeSet"/>
78
78
  <migrationRate id="migrationRateSP" spec="SkylineMatrixParameter" timesAreAges="true" processLength="@processLength" typeSet="@typeSet">
79
79
  <skylineValues id="migrationRate" spec="bella.BayesMLP" nodes="$(nodes)">
80
- <plate var="predictorFile" range="$(predictorFiles)">
81
- <predictor spec="RealParameterFromXSV" fileName="$(predictorFile)"/>
82
- </plate>
80
+ <predictor spec="RealParameterFromXSV" fileName="$(flightsPredictorFile)"/>
83
81
  <plate var="n" range="$(layersRange)">
84
82
  <weights idref="migrationRateW$(n)"/>
85
83
  </plate>
84
+ <activationFunctionsOutput spec="bella.SoftPlus"/>
86
85
  </skylineValues>
87
86
  <changeTimes spec="RealParameterFromXSV" fileName="$(changeTimesFile)"/>
88
87
  </migrationRate>
@@ -144,7 +143,7 @@
144
143
  <operator spec="BactrianScaleOperator" parameter="@gammaShape" weight="1.0"/>
145
144
  <operator spec="BactrianScaleOperator" parameter="@kappa" weight="1.0"/>
146
145
 
147
- <logger spec="Logger" fileName="MCMC.log" logEvery="1000" model="@posterior" sanitiseHeaders="true" sort="smart">
146
+ <logger spec="Logger" fileName="MCMC.log" logEvery="1000" model="@posterior">
148
147
  <log idref="posterior"/>
149
148
  <log idref="likelihood"/>
150
149
  <log idref="prior"/>
@@ -0,0 +1,36 @@
1
+ import os
2
+ from itertools import product
3
+ from pathlib import Path
4
+
5
+ from bella_companion.utils import submit_job
6
+
7
+
8
+ def run_beast():
9
+ base_output_dir = Path(os.environ["BELLA_BEAST_OUTPUT_DIR"])
10
+ output_dir = base_output_dir / "eucovid"
11
+ os.makedirs(output_dir, exist_ok=True)
12
+
13
+ base_log_dir = Path(os.environ["BELLA_SBATCH_LOG_DIR"]) / "eucovid"
14
+ data_dir = Path(__file__).parent / "data"
15
+ beast_configs_dir = Path(__file__).parent / "beast_configs"
16
+
17
+ for seed, model in product(range(3), ["GLM", "MLP"]):
18
+ extra_data = '-D layersRange="0,1,2",nodes="16 8"' if model == "MLP" else ""
19
+ os.makedirs(output_dir / model, exist_ok=True)
20
+ submit_job(
21
+ " ".join(
22
+ [
23
+ *os.environ["BELLA_RUN_BEAST_CMD"],
24
+ f"-seed {seed}",
25
+ f"-D msa_file={data_dir / 'msa.fasta'}",
26
+ f"-D changeTimesFile={data_dir / 'changetimes.csv'}",
27
+ f"-D flightsPredictorFile={data_dir / 'flights.csv'}",
28
+ extra_data,
29
+ f"-prefix {output_dir / model}{os.sep}{seed}-",
30
+ str(beast_configs_dir / f"{model}.xml"),
31
+ ]
32
+ ),
33
+ base_log_dir / model / str(seed),
34
+ cpus=128,
35
+ mem_per_cpu=12000,
36
+ )
@@ -0,0 +1,13 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class Feature:
6
+ is_binary: bool
7
+ is_relevant: bool | None = None
8
+
9
+ @property
10
+ def color(self) -> str:
11
+ if self.is_relevant is None:
12
+ return "purple"
13
+ return "#E74C3C" if self.is_relevant else "gray"
@@ -6,18 +6,18 @@ import joblib
6
6
  import matplotlib.pyplot as plt
7
7
  import numpy as np
8
8
  import polars as pl
9
- from lumiere.backend import relu, sigmoid
9
+ from bella_lumiere.backend import relu, sigmoid
10
10
 
11
- from bella_companion.simulations.figures.explain import (
12
- plot_partial_dependencies,
13
- plot_shap_features_importance,
14
- )
15
11
  from bella_companion.simulations.scenarios.epi_multitype import (
16
12
  MIGRATION_PREDICTOR,
17
13
  MIGRATION_RATE_UPPER,
18
14
  MIGRATION_RATES,
19
15
  SCENARIO,
20
16
  )
17
+ from bella_companion.utils import (
18
+ plot_partial_dependencies,
19
+ plot_shap_features_importance,
20
+ )
21
21
 
22
22
 
23
23
  def _plot_predictions(log_summary: pl.DataFrame, output_dir: Path):
@@ -6,12 +6,8 @@ import joblib
6
6
  import matplotlib.pyplot as plt
7
7
  import numpy as np
8
8
  import polars as pl
9
- from lumiere.backend import relu, sigmoid
9
+ from bella_lumiere.backend import relu, sigmoid
10
10
 
11
- from bella_companion.simulations.figures.explain import (
12
- plot_partial_dependencies,
13
- plot_shap_features_importance,
14
- )
15
11
  from bella_companion.simulations.figures.utils import step
16
12
  from bella_companion.simulations.scenarios.fbd_2traits import (
17
13
  FBD_RATE_UPPER,
@@ -20,6 +16,10 @@ from bella_companion.simulations.scenarios.fbd_2traits import (
20
16
  SCENARIO,
21
17
  STATES,
22
18
  )
19
+ from bella_companion.utils import (
20
+ plot_partial_dependencies,
21
+ plot_shap_features_importance,
22
+ )
23
23
 
24
24
 
25
25
  def _plot_predictions(log_summary: pl.DataFrame, output_dir: Path):
@@ -2,7 +2,7 @@ import numpy as np
2
2
  from numpy.random import Generator
3
3
  from phylogenie import get_epidemiological_events
4
4
 
5
- from bella_companion.simulations.features import Feature
5
+ from bella_companion.features import Feature
6
6
  from bella_companion.simulations.scenarios.common import (
7
7
  BECOME_UNINFECTIOUS_RATE,
8
8
  EPI_MAX_TIME,
@@ -3,7 +3,7 @@ from functools import partial
3
3
  import numpy as np
4
4
  from phylogenie import SkylineParameter, get_epidemiological_events
5
5
 
6
- from bella_companion.simulations.features import Feature
6
+ from bella_companion.features import Feature
7
7
  from bella_companion.simulations.scenarios.common import (
8
8
  BECOME_UNINFECTIOUS_RATE,
9
9
  EPI_MAX_TIME,
@@ -2,7 +2,7 @@ import numpy as np
2
2
  from numpy.random import Generator
3
3
  from phylogenie import SkylineVector, get_canonical_events
4
4
 
5
- from bella_companion.simulations.features import Feature
5
+ from bella_companion.features import Feature
6
6
  from bella_companion.simulations.scenarios.common import (
7
7
  FBD_MAX_TIME,
8
8
  FBD_RATE_UPPER,
@@ -3,7 +3,7 @@ from functools import partial
3
3
  import numpy as np
4
4
  from phylogenie import SkylineParameter, get_canonical_events
5
5
 
6
- from bella_companion.simulations.features import Feature
6
+ from bella_companion.features import Feature
7
7
  from bella_companion.simulations.scenarios.common import (
8
8
  FBD_MAX_TIME,
9
9
  FBD_RATE_UPPER,
@@ -6,7 +6,7 @@ from typing import Any
6
6
  from numpy.random import Generator
7
7
  from phylogenie.treesimulator import Event
8
8
 
9
- from bella_companion.simulations.features import Feature
9
+ from bella_companion.features import Feature
10
10
 
11
11
 
12
12
  class ScenarioType(Enum):
@@ -4,8 +4,8 @@ from bella_companion.utils.beast import (
4
4
  summarize_logs_dir,
5
5
  )
6
6
  from bella_companion.utils.explain import (
7
- get_median_partial_dependence_values,
8
- get_median_shap_features_importance,
7
+ plot_partial_dependencies,
8
+ plot_shap_features_importance,
9
9
  )
10
10
  from bella_companion.utils.slurm import submit_job
11
11
 
@@ -13,7 +13,7 @@ __all__ = [
13
13
  "summarize_log",
14
14
  "summarize_logs_dir",
15
15
  "read_weights_dir",
16
- "get_median_partial_dependence_values",
17
- "get_median_shap_features_importance",
16
+ "plot_partial_dependencies",
17
+ "plot_shap_features_importance",
18
18
  "submit_job",
19
19
  ]
@@ -7,9 +7,9 @@ from typing import Any
7
7
  import arviz as az
8
8
  import numpy as np
9
9
  import polars as pl
10
+ from bella_lumiere import read_log_file, read_weights
11
+ from bella_lumiere.typing import Weights
10
12
  from joblib import Parallel, delayed
11
- from lumiere import read_log_file, read_weights
12
- from lumiere.typing import Weights
13
13
  from tqdm import tqdm
14
14
 
15
15
  from bella_companion.utils.slurm import get_job_metadata
@@ -0,0 +1,7 @@
1
+ from bella_companion.utils.explain.pdp import plot_partial_dependencies
2
+ from bella_companion.utils.explain.shap import plot_shap_features_importance
3
+
4
+ __all__ = [
5
+ "plot_partial_dependencies",
6
+ "plot_shap_features_importance",
7
+ ]
@@ -1,25 +1,53 @@
1
1
  import os
2
2
  from functools import partial
3
+ from itertools import product
3
4
  from pathlib import Path
4
5
 
5
6
  import matplotlib.pyplot as plt
6
7
  import numpy as np
7
8
  import seaborn as sns
9
+ from bella_lumiere import get_partial_dependence_values
10
+ from bella_lumiere.typing import ActivationFunction, Weights
8
11
  from joblib import Parallel, delayed
9
- from lumiere.typing import ActivationFunction, Weights
12
+ from numpy.typing import ArrayLike
10
13
  from tqdm import tqdm
11
14
 
12
- from bella_companion.simulations.features import Feature
13
- from bella_companion.utils import get_median_partial_dependence_values
15
+ import bella_companion.utils.explain.typeguards as tg
16
+ from bella_companion.features import Feature
17
+
18
+
19
+ def _get_median_partial_dependence_values(
20
+ weights: list[Weights], # shape: (n_weight_samples, ...)
21
+ inputs: ArrayLike,
22
+ features_grid: list[list[float]],
23
+ hidden_activation: ActivationFunction,
24
+ output_activation: ActivationFunction,
25
+ ) -> list[list[float]]: # shape: (n_features, n_grid_points)
26
+ pdvalues = [
27
+ get_partial_dependence_values(
28
+ weights=w,
29
+ inputs=inputs,
30
+ features_grid=features_grid,
31
+ hidden_activation=hidden_activation,
32
+ output_activation=output_activation,
33
+ )
34
+ for w in weights
35
+ ]
36
+ return [
37
+ np.median([pd[feature_idx] for pd in pdvalues], axis=0).tolist()
38
+ for feature_idx in range(len(features_grid))
39
+ ]
14
40
 
15
41
 
16
42
  def plot_partial_dependencies(
17
- weights: list[list[Weights]], # shape: (n_runs, n_weights_samples, ...)
43
+ weights: list[Weights] | list[list[Weights]],
18
44
  features: dict[str, Feature],
19
- output_dir: Path,
45
+ output_dir: str | Path,
20
46
  hidden_activation: ActivationFunction,
21
47
  output_activation: ActivationFunction,
48
+ inputs: ArrayLike | None = None,
22
49
  ):
50
+ output_dir = Path(output_dir)
23
51
  os.makedirs(output_dir, exist_ok=True)
24
52
 
25
53
  continuous_grid: list[float] = np.linspace(0, 1, 10).tolist()
@@ -27,10 +55,23 @@ def plot_partial_dependencies(
27
55
  [0, 1] if feature.is_binary else continuous_grid
28
56
  for feature in features.values()
29
57
  ]
58
+ if inputs is None:
59
+ inputs = list(product(*features_grid))
60
+
61
+ if tg.is_weights_list(weights):
62
+ func = get_partial_dependence_values
63
+ elif tg.is_nested_weights_list(weights):
64
+ func = _get_median_partial_dependence_values
65
+ else:
66
+ raise ValueError(
67
+ "weights must be a list of Weights or a list of list of Weights"
68
+ )
69
+
30
70
  jobs = Parallel(n_jobs=-1, return_as="generator_unordered")(
31
71
  delayed(
32
72
  partial(
33
- get_median_partial_dependence_values,
73
+ func,
74
+ inputs=inputs,
34
75
  features_grid=features_grid,
35
76
  hidden_activation=hidden_activation,
36
77
  output_activation=output_activation,
@@ -48,25 +89,28 @@ def plot_partial_dependencies(
48
89
  if any(not f.is_binary for f in features.values()):
49
90
  for (label, feature), feature_pdvalues in zip(features.items(), pdvalues):
50
91
  if not feature.is_binary:
51
- color = "#E74C3C" if feature.is_relevant else "gray"
52
92
  median = np.median(feature_pdvalues, axis=1)
53
93
  lower = np.percentile(feature_pdvalues, 2.5, axis=1)
54
94
  high = np.percentile(feature_pdvalues, 100 - 2.5, axis=1)
55
95
  plt.fill_between( # pyright: ignore
56
- continuous_grid, lower, high, alpha=0.25, color=color
96
+ continuous_grid, lower, high, alpha=0.25, color=feature.color
57
97
  )
58
98
  for mcmc_pds in feature_pdvalues.T:
59
99
  plt.plot( # pyright: ignore
60
- continuous_grid, mcmc_pds, color=color, alpha=0.2, linewidth=1
100
+ continuous_grid,
101
+ mcmc_pds,
102
+ color=feature.color,
103
+ alpha=0.2,
104
+ linewidth=1,
61
105
  )
62
106
  plt.plot( # pyright: ignore
63
- continuous_grid, median, color=color, label=label
107
+ continuous_grid, median, color=feature.color, label=label
64
108
  )
65
- plt.xlabel("Feature value") # pyright: ignore
66
- plt.ylabel("MLP Output") # pyright: ignore
67
- plt.legend() # pyright: ignore
68
- plt.savefig(output_dir / "PDPs-continuous.svg") # pyright: ignore
69
- plt.close()
109
+ plt.xlabel("Feature value") # pyright: ignore
110
+ plt.ylabel("MLP Output") # pyright: ignore
111
+ plt.legend() # pyright: ignore
112
+ plt.savefig(output_dir / f"PDPs-continuous-{label}.svg") # pyright: ignore
113
+ plt.close()
70
114
 
71
115
  if any(f.is_binary for f in features.values()):
72
116
  data: list[float] = []
@@ -84,10 +128,9 @@ def plot_partial_dependencies(
84
128
  )
85
129
  ax.get_legend().remove() # pyright: ignore
86
130
 
87
- for i, f in enumerate([f for f in features.values() if f.is_binary]):
88
- color = "#E74C3C" if f.is_relevant else "gray"
131
+ for i, feature in enumerate([f for f in features.values() if f.is_binary]):
89
132
  for coll in ax.collections[i * 2 : i * 2 + 2]:
90
- coll.set_facecolor(color)
133
+ coll.set_facecolor(feature.color)
91
134
 
92
135
  plt.xlabel("Feature") # pyright: ignore
93
136
  plt.ylabel("MLP Output") # pyright: ignore
@@ -0,0 +1,104 @@
1
+ from functools import partial
2
+ from itertools import product
3
+ from pathlib import Path
4
+ from typing import Callable
5
+
6
+ import matplotlib.pyplot as plt
7
+ import numpy as np
8
+ import seaborn as sns
9
+ from bella_lumiere import get_shap_features_importance
10
+ from bella_lumiere.typing import ActivationFunction, Array, Weights
11
+ from joblib import Parallel, delayed
12
+ from numpy.typing import ArrayLike
13
+ from tqdm import tqdm
14
+
15
+ import bella_companion.utils.explain.typeguards as tg
16
+ from bella_companion.features import Feature
17
+
18
+
19
+ def _get_median_shap_features_importance(
20
+ weights: list[Weights],
21
+ inputs: ArrayLike,
22
+ hidden_activation: ActivationFunction,
23
+ output_activation: ActivationFunction,
24
+ ) -> list[float]: # length: n_features
25
+ features_importance = np.array(
26
+ [
27
+ get_shap_features_importance(
28
+ weights=w,
29
+ inputs=inputs,
30
+ hidden_activation=hidden_activation,
31
+ output_activation=output_activation,
32
+ )
33
+ for w in weights
34
+ ]
35
+ )
36
+ return np.median(features_importance, axis=0).tolist()
37
+
38
+
39
+ def _plot_shap_violins(
40
+ features: dict[str, Feature],
41
+ features_importance: Array, # shape: (n_samples, n_features)
42
+ output_file: str | Path,
43
+ ):
44
+ features_importance = np.asarray(features_importance)
45
+ features_importance /= features_importance.sum(axis=1, keepdims=True)
46
+
47
+ def _plot_violins(group_check: Callable[[Feature], bool]):
48
+ for i, (feature_name, feature) in enumerate(features.items()):
49
+ if group_check(feature):
50
+ sns.violinplot(
51
+ y=features_importance[:, i],
52
+ x=[feature_name] * len(features_importance),
53
+ cut=0,
54
+ color=feature.color,
55
+ )
56
+
57
+ _plot_violins(lambda f: not f.is_binary)
58
+ _plot_violins(lambda f: f.is_binary)
59
+ plt.xlabel("Feature") # pyright: ignore
60
+ plt.ylabel("Importance") # pyright: ignore
61
+ plt.savefig(output_file) # pyright: ignore
62
+ plt.close()
63
+
64
+
65
+ def plot_shap_features_importance(
66
+ weights: list[Weights] | list[list[Weights]],
67
+ features: dict[str, Feature],
68
+ output_file: str | Path,
69
+ hidden_activation: ActivationFunction,
70
+ output_activation: ActivationFunction,
71
+ inputs: ArrayLike | None = None,
72
+ ):
73
+ if inputs is None:
74
+ continuous_grid: list[float] = np.linspace(0, 1, 10).tolist()
75
+ features_grid: list[list[float]] = [
76
+ [0, 1] if feature.is_binary else continuous_grid
77
+ for feature in features.values()
78
+ ]
79
+ inputs = list(product(*features_grid))
80
+
81
+ if tg.is_weights_list(weights):
82
+ func = get_shap_features_importance
83
+ elif tg.is_nested_weights_list(weights):
84
+ func = _get_median_shap_features_importance
85
+ else:
86
+ raise ValueError(
87
+ "weights must be a list of Weights or a list of list of Weights"
88
+ )
89
+
90
+ jobs = Parallel(n_jobs=-1, return_as="generator_unordered")(
91
+ delayed(
92
+ partial(
93
+ func,
94
+ inputs=inputs,
95
+ hidden_activation=hidden_activation,
96
+ output_activation=output_activation,
97
+ )
98
+ )(w)
99
+ for w in weights
100
+ )
101
+ features_importance = np.array(
102
+ [job for job in tqdm(jobs, total=len(weights), desc="Evaluating SHAPs")]
103
+ ) # shape: (n_runs, n_features)
104
+ _plot_shap_violins(features, features_importance, output_file)
@@ -0,0 +1,20 @@
1
+ from typing import Any, TypeGuard
2
+
3
+ import numpy as np
4
+ from bella_lumiere.typing import Weights
5
+
6
+
7
+ def is_list(obj: Any) -> TypeGuard[list[Any]]:
8
+ return isinstance(obj, list)
9
+
10
+
11
+ def is_weights(obj: Any) -> TypeGuard[Weights]:
12
+ return is_list(obj) and all(isinstance(layer, np.ndarray) for layer in obj)
13
+
14
+
15
+ def is_weights_list(weights: Any) -> TypeGuard[list[Weights]]:
16
+ return is_list(weights) and all(is_weights(w) for w in weights)
17
+
18
+
19
+ def is_nested_weights_list(weights: Any) -> TypeGuard[list[list[Weights]]]:
20
+ return is_list(weights) and all(is_weights_list(w) for w in weights)