bella-companion 0.0.47__py3-none-any.whl → 0.0.48__py3-none-any.whl

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.

Potentially problematic release.


This version of bella-companion might be problematic. Click here for more details.

Files changed (60) hide show
  1. bella_companion/__pycache__/cli.cpython-310.pyc +0 -0
  2. bella_companion/__pycache__/features.cpython-310.pyc +0 -0
  3. bella_companion/eucovid/__pycache__/run_beast.cpython-310.pyc +0 -0
  4. bella_companion/eucovid/beast_configs/GLM.xml +1 -1
  5. bella_companion/eucovid/beast_configs/MLP.xml +1 -1
  6. bella_companion/eucovid/run_beast.py +18 -6
  7. bella_companion/features.py +13 -0
  8. bella_companion/platyrrhine/__pycache__/run_beast.cpython-310.pyc +0 -0
  9. bella_companion/simulations/__pycache__/run_beast.cpython-310.pyc +0 -0
  10. bella_companion/simulations/figures/__pycache__/epi_multitype.cpython-310.pyc +0 -0
  11. bella_companion/simulations/figures/__pycache__/fbd_2traits.cpython-310.pyc +0 -0
  12. bella_companion/simulations/figures/epi_multitype.py +4 -4
  13. bella_companion/simulations/figures/fbd_2traits.py +4 -4
  14. bella_companion/simulations/scenarios/__pycache__/epi_multitype.cpython-310.pyc +0 -0
  15. bella_companion/simulations/scenarios/__pycache__/epi_skyline.cpython-310.pyc +0 -0
  16. bella_companion/simulations/scenarios/__pycache__/fbd_2traits.cpython-310.pyc +0 -0
  17. bella_companion/simulations/scenarios/__pycache__/fbd_no_traits.cpython-310.pyc +0 -0
  18. bella_companion/simulations/scenarios/__pycache__/scenario.cpython-310.pyc +0 -0
  19. bella_companion/simulations/scenarios/epi_multitype.py +1 -1
  20. bella_companion/simulations/scenarios/epi_skyline.py +1 -1
  21. bella_companion/simulations/scenarios/fbd_2traits.py +1 -1
  22. bella_companion/simulations/scenarios/fbd_no_traits.py +1 -1
  23. bella_companion/simulations/scenarios/scenario.py +1 -1
  24. bella_companion/utils/__init__.py +4 -4
  25. bella_companion/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  26. bella_companion/utils/explain/__init__.py +7 -0
  27. bella_companion/utils/explain/__pycache__/__init__.cpython-310.pyc +0 -0
  28. bella_companion/utils/explain/__pycache__/pdp.cpython-310.pyc +0 -0
  29. bella_companion/utils/explain/__pycache__/shap.cpython-310.pyc +0 -0
  30. bella_companion/utils/explain/__pycache__/typeguards.cpython-310.pyc +0 -0
  31. bella_companion/{simulations/figures → utils}/explain/pdp.py +49 -13
  32. bella_companion/utils/explain/shap.py +102 -0
  33. bella_companion/utils/explain/typeguards.py +20 -0
  34. {bella_companion-0.0.47.dist-info → bella_companion-0.0.48.dist-info}/METADATA +2 -2
  35. {bella_companion-0.0.47.dist-info → bella_companion-0.0.48.dist-info}/RECORD +53 -51
  36. bella_companion/simulations/features.py +0 -7
  37. bella_companion/simulations/figures/explain/__init__.py +0 -6
  38. bella_companion/simulations/figures/explain/__pycache__/__init__.cpython-310.pyc +0 -0
  39. bella_companion/simulations/figures/explain/__pycache__/pdp.cpython-310.pyc +0 -0
  40. bella_companion/simulations/figures/explain/__pycache__/shap.cpython-310.pyc +0 -0
  41. bella_companion/simulations/figures/explain/shap.py +0 -62
  42. bella_companion/utils/explain.py +0 -45
  43. /bella_companion/eucovid/data/{case_data.tsv → case_data.csv} +0 -0
  44. /bella_companion/eucovid/data/{change_dates.tsv → change_dates.csv} +0 -0
  45. /bella_companion/eucovid/data/{osi.tsv → osi.csv} +0 -0
  46. /bella_companion/eucovid/data/predictors/all/{closedborders_7e_nt.tsv → closedborders_7e_nt.csv} +0 -0
  47. /bella_companion/eucovid/data/predictors/all/{dist_7e_ls.tsv → dist_7e_ls.csv} +0 -0
  48. /bella_companion/eucovid/data/predictors/all/{flight_7e_ls.tsv → flight_7e_ls.csv} +0 -0
  49. /bella_companion/eucovid/data/predictors/all/{flight_pop_x_7e_ls.tsv → flight_pop_x_7e_ls.csv} +0 -0
  50. /bella_companion/eucovid/data/predictors/all/{osi_x_7e_ls.tsv → osi_x_7e_ls.csv} +0 -0
  51. /bella_companion/eucovid/data/predictors/all/{osi_y_7e_ls.tsv → osi_y_7e_ls.csv} +0 -0
  52. /bella_companion/eucovid/data/predictors/all/{pop_x_7e_ls.tsv → pop_x_7e_ls.csv} +0 -0
  53. /bella_companion/eucovid/data/predictors/all/{pop_y_7e_ls.tsv → pop_y_7e_ls.csv} +0 -0
  54. /bella_companion/eucovid/data/predictors/all/{sharedborders_7e_nt.tsv → sharedborders_7e_nt.csv} +0 -0
  55. /bella_companion/eucovid/data/predictors/{changetimes_all_7e.tsv → changetimes_all_7e.csv} +0 -0
  56. /bella_companion/eucovid/data/predictors/{changetimes_flights_4e.tsv → changetimes_flights_4e.csv} +0 -0
  57. /bella_companion/eucovid/data/predictors/{flight_pop_x_4e_ls.tsv → flight_pop_x_4e_ls.csv} +0 -0
  58. {bella_companion-0.0.47.dist-info → bella_companion-0.0.48.dist-info}/WHEEL +0 -0
  59. {bella_companion-0.0.47.dist-info → bella_companion-0.0.48.dist-info}/entry_points.txt +0 -0
  60. {bella_companion-0.0.47.dist-info → bella_companion-0.0.48.dist-info}/top_level.txt +0 -0
@@ -143,7 +143,7 @@
143
143
  <operator spec="BactrianScaleOperator" parameter="@gammaShape" weight="1.0"/>
144
144
  <operator spec="BactrianScaleOperator" parameter="@kappa" weight="1.0"/>
145
145
 
146
- <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">
147
147
  <log idref="posterior"/>
148
148
  <log idref="likelihood"/>
149
149
  <log idref="prior"/>
@@ -144,7 +144,7 @@
144
144
  <operator spec="BactrianScaleOperator" parameter="@gammaShape" weight="1.0"/>
145
145
  <operator spec="BactrianScaleOperator" parameter="@kappa" weight="1.0"/>
146
146
 
147
- <logger spec="Logger" fileName="MCMC.log" logEvery="1000" model="@posterior" sanitiseHeaders="true" sort="smart">
147
+ <logger spec="Logger" fileName="MCMC.log" logEvery="1000" model="@posterior">
148
148
  <log idref="posterior"/>
149
149
  <log idref="likelihood"/>
150
150
  <log idref="prior"/>
@@ -1,5 +1,4 @@
1
1
  import os
2
- from glob import glob
3
2
  from pathlib import Path
4
3
 
5
4
  from bella_companion.utils import submit_job
@@ -17,19 +16,32 @@ def run_beast():
17
16
  msa_file = data_dir / "msa.fasta"
18
17
 
19
18
  predictors_dir = data_dir / "predictors"
20
- all_predictor_files = ",".join(glob(str(predictors_dir / "all" / "*.tsv")))
19
+ all_predictor_files = [
20
+ "dist_7e_ls",
21
+ "osi_x_7e_ls",
22
+ "osi_y_7e_ls",
23
+ "pop_y_7e_ls",
24
+ "closedborders_7e_nt",
25
+ "sharedborders_7e_nt",
26
+ "pop_x_7e_ls",
27
+ "flight_7e_ls",
28
+ "flight_pop_x_7e_ls",
29
+ ]
30
+ all_predictor_files = ",".join(
31
+ [str(predictors_dir / "all" / f"{file}.csv") for file in all_predictor_files]
32
+ )
21
33
  all_predictors_data = " ".join(
22
34
  [
23
35
  f"-D msa_file={msa_file}",
24
- f"-D changeTimesFile={predictors_dir / 'changetimes_all_7e.tsv'}",
36
+ f"-D changeTimesFile={predictors_dir / 'changetimes_all_7e.csv'}",
25
37
  f"-D predictorFiles={all_predictor_files}",
26
38
  ]
27
39
  )
28
40
  flight_predictor_data = " ".join(
29
41
  [
30
42
  f"-D msa_file={msa_file}",
31
- f"-D changeTimesFile={predictors_dir / 'changetimes_flights_4e.tsv'}",
32
- f"-D predictorFiles={predictors_dir / 'flight_pop_x_4e_ls.tsv'}",
43
+ f"-D changeTimesFile={predictors_dir / 'changetimes_flights_4e.csv'}",
44
+ f"-D predictorFiles={predictors_dir / 'flight_pop_x_4e_ls.csv'}",
33
45
  ]
34
46
  )
35
47
 
@@ -52,7 +64,6 @@ def run_beast():
52
64
  mem_per_cpu=12000,
53
65
  )
54
66
  """
55
-
56
67
  os.makedirs(output_dir / "all-predictors-GLM", exist_ok=True)
57
68
  submit_job(
58
69
  " ".join(
@@ -99,6 +110,7 @@ def run_beast():
99
110
  cpus=128,
100
111
  mem_per_cpu=12000,
101
112
  )
113
+
102
114
  """
103
115
  os.makedirs(output_dir / "flights-MLP", exist_ok=True)
104
116
  submit_job(
@@ -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"
@@ -8,16 +8,16 @@ import numpy as np
8
8
  import polars as pl
9
9
  from 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):
@@ -8,10 +8,6 @@ import numpy as np
8
8
  import polars as pl
9
9
  from 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
  ]
@@ -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
+ ]
@@ -6,20 +6,44 @@ import matplotlib.pyplot as plt
6
6
  import numpy as np
7
7
  import seaborn as sns
8
8
  from joblib import Parallel, delayed
9
- from lumiere.typing import ActivationFunction, Weights
9
+ from lumiere import get_partial_dependence_values
10
+ from lumiere.typing import ActivationFunction, ArrayLike, Weights
10
11
  from tqdm import tqdm
11
12
 
12
- from bella_companion.simulations.features import Feature
13
- from bella_companion.utils import get_median_partial_dependence_values
13
+ import bella_companion.utils.explain.typeguards as tg
14
+ from bella_companion.features import Feature
15
+
16
+
17
+ def _get_median_partial_dependence_values(
18
+ weights: list[Weights], # shape: (n_weight_samples, ...)
19
+ inputs: ArrayLike,
20
+ features_grid: list[list[float]],
21
+ hidden_activation: ActivationFunction,
22
+ output_activation: ActivationFunction,
23
+ ) -> list[list[float]]: # shape: (n_features, n_grid_points)
24
+ pdvalues = [
25
+ get_partial_dependence_values(
26
+ weights=w,
27
+ features_grid=features_grid,
28
+ hidden_activation=hidden_activation,
29
+ output_activation=output_activation,
30
+ )
31
+ for w in weights
32
+ ]
33
+ return [
34
+ np.median([pd[feature_idx] for pd in pdvalues], axis=0).tolist()
35
+ for feature_idx in range(len(features_grid))
36
+ ]
14
37
 
15
38
 
16
39
  def plot_partial_dependencies(
17
- weights: list[list[Weights]], # shape: (n_runs, n_weights_samples, ...)
40
+ weights: list[Weights] | list[list[Weights]],
18
41
  features: dict[str, Feature],
19
- output_dir: Path,
42
+ output_dir: str | Path,
20
43
  hidden_activation: ActivationFunction,
21
44
  output_activation: ActivationFunction,
22
45
  ):
46
+ output_dir = Path(output_dir)
23
47
  os.makedirs(output_dir, exist_ok=True)
24
48
 
25
49
  continuous_grid: list[float] = np.linspace(0, 1, 10).tolist()
@@ -27,10 +51,20 @@ def plot_partial_dependencies(
27
51
  [0, 1] if feature.is_binary else continuous_grid
28
52
  for feature in features.values()
29
53
  ]
54
+
55
+ if tg.is_weights_list(weights):
56
+ func = get_partial_dependence_values
57
+ elif tg.is_nested_weights_list(weights):
58
+ func = _get_median_partial_dependence_values
59
+ else:
60
+ raise ValueError(
61
+ "weights must be a list of Weights or a list of list of Weights"
62
+ )
63
+
30
64
  jobs = Parallel(n_jobs=-1, return_as="generator_unordered")(
31
65
  delayed(
32
66
  partial(
33
- get_median_partial_dependence_values,
67
+ func,
34
68
  features_grid=features_grid,
35
69
  hidden_activation=hidden_activation,
36
70
  output_activation=output_activation,
@@ -48,19 +82,22 @@ def plot_partial_dependencies(
48
82
  if any(not f.is_binary for f in features.values()):
49
83
  for (label, feature), feature_pdvalues in zip(features.items(), pdvalues):
50
84
  if not feature.is_binary:
51
- color = "#E74C3C" if feature.is_relevant else "gray"
52
85
  median = np.median(feature_pdvalues, axis=1)
53
86
  lower = np.percentile(feature_pdvalues, 2.5, axis=1)
54
87
  high = np.percentile(feature_pdvalues, 100 - 2.5, axis=1)
55
88
  plt.fill_between( # pyright: ignore
56
- continuous_grid, lower, high, alpha=0.25, color=color
89
+ continuous_grid, lower, high, alpha=0.25, color=feature.color
57
90
  )
58
91
  for mcmc_pds in feature_pdvalues.T:
59
92
  plt.plot( # pyright: ignore
60
- continuous_grid, mcmc_pds, color=color, alpha=0.2, linewidth=1
93
+ continuous_grid,
94
+ mcmc_pds,
95
+ color=feature.color,
96
+ alpha=0.2,
97
+ linewidth=1,
61
98
  )
62
99
  plt.plot( # pyright: ignore
63
- continuous_grid, median, color=color, label=label
100
+ continuous_grid, median, color=feature.color, label=label
64
101
  )
65
102
  plt.xlabel("Feature value") # pyright: ignore
66
103
  plt.ylabel("MLP Output") # pyright: ignore
@@ -84,10 +121,9 @@ def plot_partial_dependencies(
84
121
  )
85
122
  ax.get_legend().remove() # pyright: ignore
86
123
 
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"
124
+ for i, feature in enumerate([f for f in features.values() if f.is_binary]):
89
125
  for coll in ax.collections[i * 2 : i * 2 + 2]:
90
- coll.set_facecolor(color)
126
+ coll.set_facecolor(feature.color)
91
127
 
92
128
  plt.xlabel("Feature") # pyright: ignore
93
129
  plt.ylabel("MLP Output") # pyright: ignore
@@ -0,0 +1,102 @@
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 joblib import Parallel, delayed
10
+ from lumiere import get_shap_features_importance
11
+ from lumiere.typing import ActivationFunction, Array, Weights
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
+ ):
72
+ continuous_grid: list[float] = np.linspace(0, 1, 10).tolist()
73
+ features_grid: list[list[float]] = [
74
+ [0, 1] if feature.is_binary else continuous_grid
75
+ for feature in features.values()
76
+ ]
77
+ inputs = list(product(*features_grid))
78
+
79
+ if tg.is_weights_list(weights):
80
+ func = get_shap_features_importance
81
+ elif tg.is_nested_weights_list(weights):
82
+ func = _get_median_shap_features_importance
83
+ else:
84
+ raise ValueError(
85
+ "weights must be a list of Weights or a list of list of Weights"
86
+ )
87
+
88
+ jobs = Parallel(n_jobs=-1, return_as="generator_unordered")(
89
+ delayed(
90
+ partial(
91
+ func,
92
+ inputs=inputs,
93
+ hidden_activation=hidden_activation,
94
+ output_activation=output_activation,
95
+ )
96
+ )(w)
97
+ for w in weights
98
+ )
99
+ features_importance = np.array(
100
+ [job for job in tqdm(jobs, total=len(weights), desc="Evaluating SHAPs")]
101
+ ) # shape: (n_runs, n_features)
102
+ _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 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)
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bella-companion
3
- Version: 0.0.47
3
+ Version: 0.0.48
4
4
  Summary: Bayesian Evolutionary Layered Learning Architectures (BELLA) companion
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
7
7
  Requires-Dist: arviz>=0.22.0
8
- Requires-Dist: bella-lumiere>=0.0.14
8
+ Requires-Dist: bella-lumiere>=0.0.19
9
9
  Requires-Dist: dotenv>=0.9.9
10
10
  Requires-Dist: phylogenie>=3.1.4
11
11
  Requires-Dist: poetry>=2.2.1
@@ -1,32 +1,34 @@
1
1
  bella_companion/BELLA.jar,sha256=4mKDzPfz263rTqA9KS2f4Mc-UWGMuj8G48ZDonKSqVw,67408597
2
2
  bella_companion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  bella_companion/cli.py,sha256=CrtV2CG6G1nKCCVu02gtNlpHNJHLnFtSaru-LFiHKKc,3014
4
+ bella_companion/features.py,sha256=xj0iwGHhLV_4jxLmG0M-jXWejuKVFJqpB0dK8Skc9n8,283
4
5
  bella_companion/version.xml,sha256=Gr3nsYqFhVNP0Mszl_IfilxefsPN8ZpQlGlB8OJSwnE,522
5
6
  bella_companion/__pycache__/__init__.cpython-310.pyc,sha256=OWbv3-oQ0uVrCKYMlnplMpvDhv5Ytf3aYb7Eu_UONkU,151
6
- bella_companion/__pycache__/cli.cpython-310.pyc,sha256=-k34T2uplWxW_fUrSVadFAYEDos-bvonW2RDeyHuj0A,2680
7
+ bella_companion/__pycache__/cli.cpython-310.pyc,sha256=PheBrz8cVq5P6uccQxgNN8wkmBH7D3sQ2C8JIbZc9jo,2644
8
+ bella_companion/__pycache__/features.cpython-310.pyc,sha256=pSUy8FqjaRM_58Q9RYJvQERCPA4qi4HEixZk1L1AqAQ,639
7
9
  bella_companion/eucovid/__init__.py,sha256=09Ld_G7fZvCDCgEWsmaOyLVQ8pFc9QHAGnXKJ9Zm2AM,81
8
- bella_companion/eucovid/run_beast.py,sha256=wsNLqRMfloqTeXuxSUSD2ow15S-a2q1wyMVKdrDI6_E,3911
10
+ bella_companion/eucovid/run_beast.py,sha256=Cp-D_2Pg5dZn8PQ3CimY-wbHz2Ym6cjfGSetQ15YtXs,4201
9
11
  bella_companion/eucovid/__pycache__/__init__.cpython-310.pyc,sha256=cwLb8j-Jrl5beRcoZEtbpvQlG9KENPuB2F4fa1RBYIQ,248
10
- bella_companion/eucovid/__pycache__/run_beast.cpython-310.pyc,sha256=jEqqaPBugV7B8YZQjNIgYnhpCwDOV21xyG1N_IbRdJo,1922
11
- bella_companion/eucovid/beast_configs/GLM.xml,sha256=b5rAeKVEam3u2AGSJsm7EHB6LcC0l9bp1SyZT2QyjpI,10892
12
- bella_companion/eucovid/beast_configs/MLP.xml,sha256=M0_B6t0bZpjCAQqAmjrFshW96pt9sNREcoLUjwchX6Q,10616
12
+ bella_companion/eucovid/__pycache__/run_beast.cpython-310.pyc,sha256=iCSLHeal9MYoQe2WIF-nCDVf5L7dIBj9_q1jEFpHu88,1943
13
+ bella_companion/eucovid/beast_configs/GLM.xml,sha256=0aSJrQxKkHnE-zelhveIMOu0SnYl6qGCc6ryksu1org,10856
14
+ bella_companion/eucovid/beast_configs/MLP.xml,sha256=dHf1OQSXdo21Ml3y9yZ5J1tqV5A0sKbRiQp9YQ5e3fY,10580
13
15
  bella_companion/eucovid/beast_configs/Nonparametric.xml,sha256=n-t4sUfDS9AzC02tbIk5mx_RDg2l62ELhdR3I3_jjHE,17783
14
- bella_companion/eucovid/data/case_data.tsv,sha256=XaSzZh5NcEMVt9d_XlQ19T8UuEkHGrjpSFXhe9IycNg,12412
15
- bella_companion/eucovid/data/change_dates.tsv,sha256=_pmVFYiL4X9Pd79uYVgyz3sKeRap7xVcXk0OjqVhuVQ,227
16
+ bella_companion/eucovid/data/case_data.csv,sha256=XaSzZh5NcEMVt9d_XlQ19T8UuEkHGrjpSFXhe9IycNg,12412
17
+ bella_companion/eucovid/data/change_dates.csv,sha256=_pmVFYiL4X9Pd79uYVgyz3sKeRap7xVcXk0OjqVhuVQ,227
16
18
  bella_companion/eucovid/data/msa.fasta,sha256=sWaVSINSJDDLjmwlpl31JWM5VnKF7yViSpERI69glQc,4839354
17
- bella_companion/eucovid/data/osi.tsv,sha256=iTDWL_-PnVQPg_-hWROXWKNFakDq_S1fEig1A_MqMVI,9228
18
- bella_companion/eucovid/data/predictors/changetimes_all_7e.tsv,sha256=hH0xXD2lr_8RPQRqvENv6clPHauAXH22SGQHb3hlfzs,120
19
- bella_companion/eucovid/data/predictors/changetimes_flights_4e.tsv,sha256=XEepIXKRwcKknJq4-ovKlorvCypGi67B8znuQ5f1LTg,60
20
- bella_companion/eucovid/data/predictors/flight_pop_x_4e_ls.tsv,sha256=tMR9-tuGtC3rVABXUtNdV9irUX-9aCCVb_fwksHTn8U,1068
21
- bella_companion/eucovid/data/predictors/all/closedborders_7e_nt.tsv,sha256=5gP-cEzgKSCvlK0_PlkrimYGEwOaLPO0GiiM4PIKU-M,280
22
- bella_companion/eucovid/data/predictors/all/dist_7e_ls.tsv,sha256=rr71QPiJu35CYbySMJyH_GDX51D2iTIncZImwAXIvlo,1890
23
- bella_companion/eucovid/data/predictors/all/flight_7e_ls.tsv,sha256=5WztZpQrjK7puERA1oxsCn5t2G1w9NGTGKjr85gMQ54,1873
24
- bella_companion/eucovid/data/predictors/all/flight_pop_x_7e_ls.tsv,sha256=qfRTXyZItzEm8pxurhFYO-DvpJXD-J4lMH5eyZKF0aE,1862
25
- bella_companion/eucovid/data/predictors/all/osi_x_7e_ls.tsv,sha256=kke2eHlVuc84qMj1WBllhBG2BQt7JHUWDZeiVoAP8Lw,1900
26
- bella_companion/eucovid/data/predictors/all/osi_y_7e_ls.tsv,sha256=5YDXe4GstyyRKP15213cAAEm5lVFW_bC98R8ipc1XoE,1900
27
- bella_companion/eucovid/data/predictors/all/pop_x_7e_ls.tsv,sha256=3fVYRQ1ylwsa7YptMU8f_xELwwqIF3Ux8akL9UaXKis,1904
28
- bella_companion/eucovid/data/predictors/all/pop_y_7e_ls.tsv,sha256=Ku39Ts0HW9r5lThAZ01V7HJDi0aoRYs0aQs5EXlZCkQ,1904
29
- bella_companion/eucovid/data/predictors/all/sharedborders_7e_nt.tsv,sha256=pPVT5DIaZuc3B0mSs-B3kw3G2zja1LfmL_xLwlNtLDo,280
19
+ bella_companion/eucovid/data/osi.csv,sha256=iTDWL_-PnVQPg_-hWROXWKNFakDq_S1fEig1A_MqMVI,9228
20
+ bella_companion/eucovid/data/predictors/changetimes_all_7e.csv,sha256=hH0xXD2lr_8RPQRqvENv6clPHauAXH22SGQHb3hlfzs,120
21
+ bella_companion/eucovid/data/predictors/changetimes_flights_4e.csv,sha256=XEepIXKRwcKknJq4-ovKlorvCypGi67B8znuQ5f1LTg,60
22
+ bella_companion/eucovid/data/predictors/flight_pop_x_4e_ls.csv,sha256=tMR9-tuGtC3rVABXUtNdV9irUX-9aCCVb_fwksHTn8U,1068
23
+ bella_companion/eucovid/data/predictors/all/closedborders_7e_nt.csv,sha256=5gP-cEzgKSCvlK0_PlkrimYGEwOaLPO0GiiM4PIKU-M,280
24
+ bella_companion/eucovid/data/predictors/all/dist_7e_ls.csv,sha256=rr71QPiJu35CYbySMJyH_GDX51D2iTIncZImwAXIvlo,1890
25
+ bella_companion/eucovid/data/predictors/all/flight_7e_ls.csv,sha256=5WztZpQrjK7puERA1oxsCn5t2G1w9NGTGKjr85gMQ54,1873
26
+ bella_companion/eucovid/data/predictors/all/flight_pop_x_7e_ls.csv,sha256=qfRTXyZItzEm8pxurhFYO-DvpJXD-J4lMH5eyZKF0aE,1862
27
+ bella_companion/eucovid/data/predictors/all/osi_x_7e_ls.csv,sha256=kke2eHlVuc84qMj1WBllhBG2BQt7JHUWDZeiVoAP8Lw,1900
28
+ bella_companion/eucovid/data/predictors/all/osi_y_7e_ls.csv,sha256=5YDXe4GstyyRKP15213cAAEm5lVFW_bC98R8ipc1XoE,1900
29
+ bella_companion/eucovid/data/predictors/all/pop_x_7e_ls.csv,sha256=3fVYRQ1ylwsa7YptMU8f_xELwwqIF3Ux8akL9UaXKis,1904
30
+ bella_companion/eucovid/data/predictors/all/pop_y_7e_ls.csv,sha256=Ku39Ts0HW9r5lThAZ01V7HJDi0aoRYs0aQs5EXlZCkQ,1904
31
+ bella_companion/eucovid/data/predictors/all/sharedborders_7e_nt.csv,sha256=pPVT5DIaZuc3B0mSs-B3kw3G2zja1LfmL_xLwlNtLDo,280
30
32
  bella_companion/platyrrhine/__init__.py,sha256=gySgNPoKaEdhcZppKMsCmS-aAcYw_rDEw0viz72Udaw,259
31
33
  bella_companion/platyrrhine/beast_config.xml,sha256=bLzavt-Zd8cmSgQQnlCBfZ9KyM7d1inOGx12VNjPFb4,7056
32
34
  bella_companion/platyrrhine/results.py,sha256=aRx9MkI43f5bhr-16UkShDH-_oMNFzhHxfU2WK1L3BY,7468
@@ -34,14 +36,13 @@ bella_companion/platyrrhine/run_beast.py,sha256=t1gUmn_HEXKqxgGXYCdohGDWeL-QEpW7
34
36
  bella_companion/platyrrhine/summarize.py,sha256=Qc3GE2vUspTqU_QjLdULvK0r7AZ3JTdqsBmd71izt7M,1356
35
37
  bella_companion/platyrrhine/__pycache__/__init__.cpython-310.pyc,sha256=_7OOgWWr8apuTVm7TLhvmP41QHTDFlDNjTtJ9J3vpZc,425
36
38
  bella_companion/platyrrhine/__pycache__/results.cpython-310.pyc,sha256=ytoolBYXSbQHjso0byIJXWwGSE94TeM5ko8L0tOCrTk,6627
37
- bella_companion/platyrrhine/__pycache__/run_beast.cpython-310.pyc,sha256=Z5nfOPwht1yR_uDJoTt2Zj-ZR_Tr-QeIqGWtZYEBbBQ,2172
39
+ bella_companion/platyrrhine/__pycache__/run_beast.cpython-310.pyc,sha256=odxK2WgloFy-UAyGiZSzYGVGlJhvxstI5VqDVqZnOPc,2186
38
40
  bella_companion/platyrrhine/__pycache__/summarize.cpython-310.pyc,sha256=m9ruJb4uO_az3qn4T8Iq3zPR0LSsFLBjeISn6y5-DXM,1622
39
41
  bella_companion/platyrrhine/__pycache__/summarize_logs.cpython-310.pyc,sha256=yKvebBShpNqMoVI2g3VzseuJrMG43A8U8vF7Yg288AE,1616
40
42
  bella_companion/platyrrhine/data/change_times.csv,sha256=tedobHbaY7-6M3V6F6HSqGAU9dpeeajR5mu1XGJfp6w,68
41
43
  bella_companion/platyrrhine/data/traits.csv,sha256=N_mCnaM9Gy0Qot7-l_mK0vMvr7e_5BZ4bgUHpcoG9UM,3949
42
44
  bella_companion/platyrrhine/data/trees.nwk,sha256=lpSiGUG5s3zE--IKPOyWrJ5vpJb_xAPnfxychs3YNIs,488232
43
45
  bella_companion/simulations/__init__.py,sha256=gjO_QB2wp335l7UO-zA9fFQ5vmZauGItBuO-QZFu93E,439
44
- bella_companion/simulations/features.py,sha256=DZOBpJGlQ0UinqUZYbEtoemZ2eQGVLV_i-DfpW31qJI,104
45
46
  bella_companion/simulations/generate_data.py,sha256=edfhXrs76hl30i_xizup4z6qgzXZyaDzX_PVC62Ytpw,849
46
47
  bella_companion/simulations/generate_figures.py,sha256=r3zGKnLGDpuVzzWVQIumkt1sTMl_4w1iKnVNy-fTJAg,371
47
48
  bella_companion/simulations/metrics.py,sha256=kSX7-B4a-LDm1V--S8CvEJDktlJ8qkpo_gY6V7XbOXw,1930
@@ -52,7 +53,7 @@ bella_companion/simulations/__pycache__/features.cpython-310.pyc,sha256=lKPxu0ft
52
53
  bella_companion/simulations/__pycache__/generate_data.cpython-310.pyc,sha256=02XU0jjLp_OpbdRXHCuESRb7gLIPc6r7ZlgWOt90oTc,1273
53
54
  bella_companion/simulations/__pycache__/generate_figures.cpython-310.pyc,sha256=tU90zwDopaeqgz5v7p_uMnVmdZoRqxN84-zsiKu1t-U,560
54
55
  bella_companion/simulations/__pycache__/metrics.cpython-310.pyc,sha256=39dzyU2PWUDpR0npJlO-MMha1jTFJ40sDQF9BLhPZRE,2652
55
- bella_companion/simulations/__pycache__/run_beast.cpython-310.pyc,sha256=ByrndOcAAyCJ8vOCCSsISLPjGRMDzkDCsZAqMge2iAw,2635
56
+ bella_companion/simulations/__pycache__/run_beast.cpython-310.pyc,sha256=OM1hpGGmC_MG86LRGqvOQxPr3JhEcoh7ht-u_9yNSEw,2655
56
57
  bella_companion/simulations/__pycache__/summarize.cpython-310.pyc,sha256=bIi5Iwro1QlZ5iDtdoG_Ze4mW-2yWHglyeaRWpbUXdI,1340
57
58
  bella_companion/simulations/__pycache__/summarize_logs.cpython-310.pyc,sha256=N3unUXsBHq5rrC4GHK6i0O0uzh71AIGdPFN3Lxb-el8,1359
58
59
  bella_companion/simulations/beast_configs/epi-multitype/GLM.xml,sha256=VymAYsaZVuB3EPE0DCQSXpKepVq8pPjKaB5yhEpaVkE,4334
@@ -68,49 +69,50 @@ bella_companion/simulations/beast_configs/fbd-no-traits/GLM.xml,sha256=Caq7Gxqx-
68
69
  bella_companion/simulations/beast_configs/fbd-no-traits/MLP.xml,sha256=JE_cGh2DW5yPAXyXXr0D3DlovmV-aIbze7qrhENHK3w,4275
69
70
  bella_companion/simulations/beast_configs/fbd-no-traits/Nonparametric.xml,sha256=m2xaHZwskCFInvVY1QH1fwQqH6p_fgESlPX2BbBeUhk,2822
70
71
  bella_companion/simulations/figures/__init__.py,sha256=LeHPeBb4vxJo0pxLZi_9s6iRBKvWC32yhAZBByqK2_8,590
71
- bella_companion/simulations/figures/epi_multitype.py,sha256=Ni-hqIiPw0XV_WlypVQD7M1wlpDVz089SqIHly6NsLM,2643
72
+ bella_companion/simulations/figures/epi_multitype.py,sha256=AqzYrUl0QTqnZgaf3Kxtzw7jRDI2jWlGTTUGDGoN84w,2621
72
73
  bella_companion/simulations/figures/epi_skyline.py,sha256=SyFOsb8dwLuoN5IOCiQbG-ZCPDS8Wua_LL-cOuLtu_s,1673
73
- bella_companion/simulations/figures/fbd_2traits.py,sha256=eU302inVrFDFvKLqNb6t7Z69HLrG0tBrDqRp9AlIjac,2742
74
+ bella_companion/simulations/figures/fbd_2traits.py,sha256=Bdbos_sT0CYu8HSHUMNPmBJM0kgySpbgknwZxMHZUu0,2720
74
75
  bella_companion/simulations/figures/fbd_no_traits.py,sha256=-_c-qnrFAYZ7vd4Ieeb-uYA3VUwURfrcP11BN9PG8JY,1907
75
76
  bella_companion/simulations/figures/scenarios.py,sha256=gbMz1TUxxT2RSIq2kQlFioNdgSHk-gQY2OQuf6-7Fww,2817
76
77
  bella_companion/simulations/figures/utils.py,sha256=0M5OrxaEuqcj9rR2uAc_O7utQvhEceZGH0sKrGRWaWs,3129
77
78
  bella_companion/simulations/figures/__pycache__/__init__.cpython-310.pyc,sha256=hCtbzMhTC_u8-mCqttWA6ZIWKWxEMuqCZRBPcc2UJrg,693
78
- bella_companion/simulations/figures/__pycache__/epi_multitype.cpython-310.pyc,sha256=67fkvg26_7BBIdGC9W9yw6xe46EXygCVgSkg8pSffOg,2716
79
+ bella_companion/simulations/figures/__pycache__/epi_multitype.cpython-310.pyc,sha256=GGLGKw8f3tfXB0nmSPGYYWbM4-BuOWlbQ2_yV727Ghg,2694
79
80
  bella_companion/simulations/figures/__pycache__/epi_skyline.cpython-310.pyc,sha256=zFWaeMyNQkynbJGZ--ya9YjviunoL5o8mlnjxxRHuRE,1705
80
- bella_companion/simulations/figures/__pycache__/fbd_2traits.cpython-310.pyc,sha256=_URcHHm3IbMcDHDf3m_DWrwuhzArIQtESxJttcS71yc,2764
81
+ bella_companion/simulations/figures/__pycache__/fbd_2traits.cpython-310.pyc,sha256=v6PUTeLC4N3TZ_BkbLE7EPT8jFkimgQX680wj3v-GYI,2742
81
82
  bella_companion/simulations/figures/__pycache__/fbd_no_traits.cpython-310.pyc,sha256=GUqMEJSVrtei5kAs-OEVwW6ETcY6RLXtYGqK-xue4c0,1781
82
83
  bella_companion/simulations/figures/__pycache__/scenarios.cpython-310.pyc,sha256=Dlp6Dg5sMkwA5vScLd1TQH0v_q6k3JLeF8TyB7Oes5Y,2140
83
84
  bella_companion/simulations/figures/__pycache__/utils.cpython-310.pyc,sha256=gr5wL9ASi0ZS34_rEeIxKrmE-Aw1nORq-DbEDCLnXfU,3979
84
- bella_companion/simulations/figures/explain/__init__.py,sha256=DnmVIWO65nTT5VsWnbS7NyYgKEY_eo4oMCtCY_ML2Vk,260
85
- bella_companion/simulations/figures/explain/pdp.py,sha256=3n3ssgufW_43pn2hO5V5J_jgcJH3Fpb8stIRtTnlQ8w,3801
86
- bella_companion/simulations/figures/explain/shap.py,sha256=1PkbCgynbW-PXkkRpIcY7JoBYqOxqmu1OEOif_roFY8,2207
87
- bella_companion/simulations/figures/explain/__pycache__/__init__.cpython-310.pyc,sha256=fTqKAgUlMz5E6IXn_bFMd2H5ZzUkF0RAkhZdmC1BOpg,407
88
- bella_companion/simulations/figures/explain/__pycache__/pdp.cpython-310.pyc,sha256=_Np-khsYmnoISKlyt-5v-A6lTkqdqy5rQMV3VfqH81U,3474
89
- bella_companion/simulations/figures/explain/__pycache__/shap.cpython-310.pyc,sha256=5IY_KT6WrAKbkbttaUVTBT-NrsuL5TrI6JDpqLubEHU,2756
90
85
  bella_companion/simulations/scenarios/__init__.py,sha256=3Kl1lKcFpfb3vLX64DmSW4XCF5kXU1ZoHtstFH-ZIzU,876
91
86
  bella_companion/simulations/scenarios/common.py,sha256=_ddaSuTvEVdttGkXB4HPc2B7IB1F_GBOCW3cVOPZ-ZM,807
92
- bella_companion/simulations/scenarios/epi_multitype.py,sha256=fTkFeGHxyV_1f2nX3g_Oyr_e6wkorhXEicJjIAgeZKA,2439
93
- bella_companion/simulations/scenarios/epi_skyline.py,sha256=JqnOVATECxBUqEbkR5lBlMI2O8k4hO6ipR8k9cHUsm0,2365
94
- bella_companion/simulations/scenarios/fbd_2traits.py,sha256=-amB3NX0GsVgYbFuHH71t93FuXUEnRUyhWf2Qpcpia4,3541
95
- bella_companion/simulations/scenarios/fbd_no_traits.py,sha256=R6CH0fVeQg-Iesl39pq2uY8ICVEO4VZbvUVUCGwauJU,2520
96
- bella_companion/simulations/scenarios/scenario.py,sha256=_FRWAyOFbw94lAzd3zCD-1ek4TrssoiXfXRQPShLiIA,620
87
+ bella_companion/simulations/scenarios/epi_multitype.py,sha256=hgl2-m9gPm6OntnOZeRfquflbXFuu2Kt4RmKinSslYo,2427
88
+ bella_companion/simulations/scenarios/epi_skyline.py,sha256=iLwsGw-DZK8QOIGhMRUyvFRDEwFrksSx46s2DB6sr0U,2353
89
+ bella_companion/simulations/scenarios/fbd_2traits.py,sha256=-BNJMx-4GGW32IaTDxwVOHs2ZW7z781GJn-tMycygcI,3529
90
+ bella_companion/simulations/scenarios/fbd_no_traits.py,sha256=OsJP2bJVswLgeerXSM0ULKnj5_lxRVHCCoENjs_fWPM,2508
91
+ bella_companion/simulations/scenarios/scenario.py,sha256=oV9yxxD_De5YdCLbAwIFLmiRXqOaoflJjTIkY2yu5M8,608
97
92
  bella_companion/simulations/scenarios/__pycache__/__init__.cpython-310.pyc,sha256=u8Myq0Jl4dr5i0IzQoZiBxkGfEHQrLfhS2gRnPgFm-g,1081
98
93
  bella_companion/simulations/scenarios/__pycache__/common.cpython-310.pyc,sha256=qLAVMzuY5Q2YGmeUlaLUqa_81dAdhKnX2FkYdC82GEw,1226
99
- bella_companion/simulations/scenarios/__pycache__/epi_multitype.cpython-310.pyc,sha256=qyesYumfFnaXSenM1T0p1sjqDKUnzT_-aMWt0bPEJ9Q,2390
100
- bella_companion/simulations/scenarios/__pycache__/epi_skyline.cpython-310.pyc,sha256=wg5eyiA3grtlNE0KzSr-xAQaYHdw2d5UjpFT_MSXoyM,2194
101
- bella_companion/simulations/scenarios/__pycache__/fbd_2traits.cpython-310.pyc,sha256=gg15HCp0Q_oqOxXYrbM9uOPjw58HpRNVWexO5p6Jb14,3028
102
- bella_companion/simulations/scenarios/__pycache__/fbd_no_traits.cpython-310.pyc,sha256=TMz7ljrkXDCwKlqKP1wSOfbxvqvkFfzzUwZSqQtaQMs,2637
103
- bella_companion/simulations/scenarios/__pycache__/scenario.cpython-310.pyc,sha256=1cWwz_MoZopfAt9ErEbWZnLutFODPwkujkTkS2NHsQg,1147
104
- bella_companion/utils/__init__.py,sha256=UtMwPK9dWf9NAl0ic8CSsgdW7aSm-5J49OqgvD7UpYw,480
94
+ bella_companion/simulations/scenarios/__pycache__/epi_multitype.cpython-310.pyc,sha256=0eZdEZydqVYfxUfbvCSaekXdK4hOo6BTeCW5b3DbC8E,2378
95
+ bella_companion/simulations/scenarios/__pycache__/epi_skyline.cpython-310.pyc,sha256=ykUAU_2rmZFSUlX2w2BjcXHHl96pgKRlybc2_au4G9k,2182
96
+ bella_companion/simulations/scenarios/__pycache__/fbd_2traits.cpython-310.pyc,sha256=NeuiFFfzapaIpFQTRft98_O_8Ev3QRvjBf7EUnBI9GI,3016
97
+ bella_companion/simulations/scenarios/__pycache__/fbd_no_traits.cpython-310.pyc,sha256=c23AIXVYvmOPb7a-QZW7vledSJc9pyF9V-JdFLSJzFY,2625
98
+ bella_companion/simulations/scenarios/__pycache__/scenario.cpython-310.pyc,sha256=5vItlXtuoVrud9y1Imm0RgKbEfUfYV9Jo5KJqXEiWDw,1135
99
+ bella_companion/utils/__init__.py,sha256=Ehu8rgO6T2ie_BHW25I0-huoBIHPtknkHYvoUr-37BY,446
105
100
  bella_companion/utils/beast.py,sha256=TBa0cLklX1_tXqoQE4LRYvds7mLg_9fS2-6U6OHENHo,2184
106
- bella_companion/utils/explain.py,sha256=uP7HPyn2YiykAI69BQV3RooDpC6qKoCLXfp3Uibp4zk,1475
107
101
  bella_companion/utils/slurm.py,sha256=xEyf-Jxk8fy71t3fko_Ic9WtUFSdLFE3w4tR17gaBPw,1868
108
- bella_companion/utils/__pycache__/__init__.cpython-310.pyc,sha256=QKECw9gSF8x3G4oXI06atZpaLDPSxm3k4qJ_-0nADbo,527
102
+ bella_companion/utils/__pycache__/__init__.cpython-310.pyc,sha256=vsEVlE0toSUCPJ-nxp6PcdvSG26wA3JGM4QqeXjsh_U,510
109
103
  bella_companion/utils/__pycache__/beast.cpython-310.pyc,sha256=OeIB4XTx6zZnQG1Eikaf-qUfC5ONSGnMeDVbhdIyHSU,2537
110
104
  bella_companion/utils/__pycache__/explain.cpython-310.pyc,sha256=K7YHxY520Q0nJtTVa-eEKw3B99MsrO_b-U50X_yihGQ,1819
111
105
  bella_companion/utils/__pycache__/slurm.cpython-310.pyc,sha256=kKWmJwCTlotpPuXi4kzXNx2-zY9BXuzjhGi5ZrcN0oI,1785
112
- bella_companion-0.0.47.dist-info/METADATA,sha256=MMvsZAJNo1nikOwAlFZwYbvITPB-wW2iSRB2sxW7NbY,392
113
- bella_companion-0.0.47.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
114
- bella_companion-0.0.47.dist-info/entry_points.txt,sha256=SVEYDBrkBWPrOGwnEH2aO5TSVIAvfKE37sqm-9ut9jg,51
115
- bella_companion-0.0.47.dist-info/top_level.txt,sha256=q0loZYv4vf3zF_tOATyAJqeyLOEuPyLbObNqIGP7Fmc,16
116
- bella_companion-0.0.47.dist-info/RECORD,,
106
+ bella_companion/utils/explain/__init__.py,sha256=ksk8HWIpdiMhT4lW7H_05p_s44ihMiHHNM2TJGO9vz4,234
107
+ bella_companion/utils/explain/pdp.py,sha256=Jn0N2ukrAxjN1jHdWEjg-2FW4kAxNQKwFSWDxjh0xIk,4845
108
+ bella_companion/utils/explain/shap.py,sha256=vhik04JB9ol4ZLSKA6v7J76As-xvK3o2sUzQFanAOkc,3357
109
+ bella_companion/utils/explain/typeguards.py,sha256=OEmpMztsnBcqBFfTEn6Eg4XemtuNVpBljzwj1K4_taI,585
110
+ bella_companion/utils/explain/__pycache__/__init__.cpython-310.pyc,sha256=PGWF9xovDhEAsB-WeysWYiuBtNmo6l4APH25HNA_dAc,369
111
+ bella_companion/utils/explain/__pycache__/pdp.cpython-310.pyc,sha256=oXZcdKi8LsE53Ou0LBhVCblWtdyQ_0WSNYA0rBeSI4E,4534
112
+ bella_companion/utils/explain/__pycache__/shap.cpython-310.pyc,sha256=tmYdrpFbXe5xqtjAv-fJCp0sziiupADdH4lQXcFub-w,3747
113
+ bella_companion/utils/explain/__pycache__/typeguards.cpython-310.pyc,sha256=nYds3jsM7aMCEtw_3dnxtX7n1_IU0Lw0niURvxUegNY,1294
114
+ bella_companion-0.0.48.dist-info/METADATA,sha256=ciIfEDN_a9wfPUu2B6kDJaP6ufnllF8CJ-fGiXpP21Q,392
115
+ bella_companion-0.0.48.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
116
+ bella_companion-0.0.48.dist-info/entry_points.txt,sha256=SVEYDBrkBWPrOGwnEH2aO5TSVIAvfKE37sqm-9ut9jg,51
117
+ bella_companion-0.0.48.dist-info/top_level.txt,sha256=q0loZYv4vf3zF_tOATyAJqeyLOEuPyLbObNqIGP7Fmc,16
118
+ bella_companion-0.0.48.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- from dataclasses import dataclass
2
-
3
-
4
- @dataclass
5
- class Feature:
6
- is_binary: bool
7
- is_relevant: bool
@@ -1,6 +0,0 @@
1
- from bella_companion.simulations.figures.explain.pdp import plot_partial_dependencies
2
- from bella_companion.simulations.figures.explain.shap import (
3
- plot_shap_features_importance,
4
- )
5
-
6
- __all__ = ["plot_partial_dependencies", "plot_shap_features_importance"]
@@ -1,62 +0,0 @@
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 joblib import Parallel, delayed
10
- from lumiere.typing import ActivationFunction, Weights
11
- from tqdm import tqdm
12
-
13
- from bella_companion.simulations.features import Feature
14
- from bella_companion.utils import get_median_shap_features_importance
15
-
16
-
17
- def plot_shap_features_importance(
18
- weights: list[list[Weights]], # shape: (n_runs, n_weights_samples, ...)
19
- features: dict[str, Feature],
20
- output_file: Path,
21
- hidden_activation: ActivationFunction,
22
- output_activation: ActivationFunction,
23
- ):
24
- continuous_grid: list[float] = np.linspace(0, 1, 10).tolist()
25
- features_grid: list[list[float]] = [
26
- [0, 1] if feature.is_binary else continuous_grid
27
- for feature in features.values()
28
- ]
29
- inputs = list(product(*features_grid))
30
-
31
- jobs = Parallel(n_jobs=-1, return_as="generator_unordered")(
32
- delayed(
33
- partial(
34
- get_median_shap_features_importance,
35
- inputs=inputs,
36
- hidden_activation=hidden_activation,
37
- output_activation=output_activation,
38
- )
39
- )(w)
40
- for w in weights
41
- )
42
- features_importances = np.array(
43
- [job for job in tqdm(jobs, total=len(weights), desc="Evaluating SHAPs")]
44
- ) # shape: (n_runs, n_features)
45
- features_importances /= features_importances.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_importances[:, i],
52
- x=[feature_name] * len(features_importances),
53
- cut=0,
54
- color="#E74C3C" if feature.is_relevant else "gray",
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()
@@ -1,45 +0,0 @@
1
- import numpy as np
2
- from lumiere import get_partial_dependence_values, get_shap_features_importance
3
- from lumiere.typing import ActivationFunction, Weights
4
- from numpy.typing import ArrayLike
5
-
6
-
7
- def get_median_partial_dependence_values(
8
- weights: list[Weights], # shape: (n_weight_samples, ...)
9
- features_grid: list[list[float]],
10
- hidden_activation: ActivationFunction,
11
- output_activation: ActivationFunction,
12
- ) -> list[list[float]]: # shape: (n_features, n_grid_points)
13
- pdvalues = [
14
- get_partial_dependence_values(
15
- weights=w,
16
- features_grid=features_grid,
17
- hidden_activation=hidden_activation,
18
- output_activation=output_activation,
19
- )
20
- for w in weights
21
- ]
22
- return [
23
- np.median([pd[feature_idx] for pd in pdvalues], axis=0).tolist()
24
- for feature_idx in range(len(features_grid))
25
- ]
26
-
27
-
28
- def get_median_shap_features_importance(
29
- weights: list[Weights],
30
- inputs: ArrayLike,
31
- hidden_activation: ActivationFunction,
32
- output_activation: ActivationFunction,
33
- ) -> list[float]: # length: n_features
34
- features_importance = np.array(
35
- [
36
- get_shap_features_importance(
37
- weights=w,
38
- inputs=inputs,
39
- hidden_activation=hidden_activation,
40
- output_activation=output_activation,
41
- )
42
- for w in weights
43
- ]
44
- )
45
- return np.median(features_importance, axis=0).tolist()
File without changes