bella-companion 0.0.42__py3-none-any.whl → 0.0.44__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.

Binary file
bella_companion/cli.py CHANGED
@@ -15,6 +15,18 @@ from bella_companion.simulations import summarize_logs as summarize_simulations
15
15
 
16
16
  def main():
17
17
  load_dotenv(Path(os.getcwd()) / ".env")
18
+ os.environ["BELLA_RUN_BEAST_CMD"] = " ".join(
19
+ [
20
+ "java",
21
+ os.getenv("JAVA_OPTIONS", ""),
22
+ f"-jar {Path(__file__).parent / 'BELLA.jar'}",
23
+ f"-version_file {Path(__file__).parent / 'version.xml'}",
24
+ "-seed 42",
25
+ "-overwrite",
26
+ "-statefile /tmp/state",
27
+ "-DFout /dev/null",
28
+ ]
29
+ )
18
30
 
19
31
  parser = argparse.ArgumentParser(
20
32
  prog="bella",
@@ -1,15 +1,7 @@
1
- from bella_companion.simulations.figures.epi_multitype_results import (
2
- plot_epi_multitype_results,
3
- )
4
- from bella_companion.simulations.figures.epi_skyline_results import (
5
- plot_epi_skyline_results,
6
- )
7
- from bella_companion.simulations.figures.fbd_2traits_results import (
8
- plot_fbd_2traits_results,
9
- )
10
- from bella_companion.simulations.figures.fbd_no_traits_results import (
11
- plot_fbd_no_traits_results,
12
- )
1
+ from bella_companion.simulations.figures.epi_multitype import plot_epi_multitype_results
2
+ from bella_companion.simulations.figures.epi_skyline import plot_epi_skyline_results
3
+ from bella_companion.simulations.figures.fbd_2traits import plot_fbd_2traits_results
4
+ from bella_companion.simulations.figures.fbd_no_traits import plot_fbd_no_traits_results
13
5
  from bella_companion.simulations.figures.scenarios import plot_scenarios
14
6
 
15
7
  __all__ = [
@@ -14,8 +14,7 @@ from bella_companion.simulations.scenarios.epi_skyline import REPRODUCTION_NUMBE
14
14
 
15
15
 
16
16
  def plot_epi_skyline_results():
17
- output_dir = Path(os.environ["BELLA_FIGURES_DIR"]) / "epi-skyline-results"
18
- os.makedirs(output_dir, exist_ok=True)
17
+ base_output_dir = Path(os.environ["BELLA_FIGURES_DIR"]) / "epi-skyline"
19
18
 
20
19
  for i, reproduction_number in enumerate(REPRODUCTION_NUMBERS, start=1):
21
20
  summaries_dir = Path(os.environ["BELLA_LOG_SUMMARIES_DIR"]) / f"epi-skyline_{i}"
@@ -26,6 +25,8 @@ def plot_epi_skyline_results():
26
25
  }
27
26
  true_values = {"reproductionNumberSP": reproduction_number}
28
27
 
28
+ output_dir = base_output_dir / str(i)
29
+ os.makedirs(output_dir, exist_ok=True)
29
30
  for log_summary in logs_summaries.values():
30
31
  step(
31
32
  [
@@ -35,12 +36,10 @@ def plot_epi_skyline_results():
35
36
  )
36
37
  step(reproduction_number, color="k", linestyle="--")
37
38
  plt.ylabel("Reproduction number") # pyright: ignore
38
- plt.savefig(output_dir / f"predictions-{i}.svg") # pyright: ignore
39
+ plt.savefig(output_dir / "predictions.svg") # pyright: ignore
39
40
  plt.close()
40
41
 
41
42
  plot_coverage_per_time_bin(
42
- logs_summaries, true_values, output_dir / f"coverage-{i}.svg"
43
- )
44
- plot_maes_per_time_bin(
45
- logs_summaries, true_values, output_dir / f"maes-{i}.svg"
43
+ logs_summaries, true_values, output_dir / "coverage.svg"
46
44
  )
45
+ plot_maes_per_time_bin(logs_summaries, true_values, output_dir / "maes.svg")
@@ -1,6 +1,7 @@
1
1
  from functools import partial
2
2
  from itertools import product
3
3
  from pathlib import Path
4
+ from typing import Callable
4
5
 
5
6
  import matplotlib.pyplot as plt
6
7
  import numpy as np
@@ -43,13 +44,18 @@ def plot_shap_features_importance(
43
44
  ) # shape: (n_runs, n_features)
44
45
  features_importances /= features_importances.sum(axis=1, keepdims=True)
45
46
 
46
- for i, (feature_name, feature) in enumerate(features.items()):
47
- sns.violinplot(
48
- y=features_importances[:, i],
49
- x=[feature_name] * len(features_importances),
50
- cut=0,
51
- color="#E74C3C" if feature.is_relevant else "gray",
52
- )
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)
53
59
  plt.xlabel("Feature") # pyright: ignore
54
60
  plt.ylabel("Importance") # pyright: ignore
55
61
  plt.savefig(output_file) # pyright: ignore
@@ -14,8 +14,7 @@ from bella_companion.simulations.scenarios.fbd_no_traits import RATES
14
14
 
15
15
 
16
16
  def plot_fbd_no_traits_results():
17
- output_dir = Path(os.environ["BELLA_FIGURES_DIR"]) / "fbd-no-traits-predictions"
18
- os.makedirs(output_dir, exist_ok=True)
17
+ base_output = Path(os.environ["BELLA_FIGURES_DIR"]) / "fbd-no-traits"
19
18
 
20
19
  for i, rates in enumerate(RATES, start=1):
21
20
  summaries_dir = (
@@ -28,6 +27,7 @@ def plot_fbd_no_traits_results():
28
27
  }
29
28
  true_values = {"birthRateSP": rates["birth"], "deathRateSP": rates["death"]}
30
29
 
30
+ output_dir = base_output / str(i)
31
31
  for id, rate in true_values.items():
32
32
  for log_summary in logs_summaries.values():
33
33
  step(
@@ -41,18 +41,18 @@ def plot_fbd_no_traits_results():
41
41
  plt.ylabel( # pyright: ignore
42
42
  r"$\lambda$" if id == "birthRateSP" else r"$\mu$"
43
43
  )
44
- plt.savefig(output_dir / f"{id}-predictions-{i}-.svg") # pyright: ignore
44
+ plt.savefig(output_dir / f"{id}-predictions.svg") # pyright: ignore
45
45
  plt.close()
46
46
 
47
47
  plot_coverage_per_time_bin(
48
48
  logs_summaries,
49
49
  true_values,
50
- output_dir / f"coverage-{i}.svg",
50
+ output_dir / "coverage.svg",
51
51
  reverse_xticks=True,
52
52
  )
53
53
  plot_maes_per_time_bin(
54
54
  logs_summaries,
55
55
  true_values,
56
- output_dir / f"maes-{i}.svg",
56
+ output_dir / "maes.svg",
57
57
  reverse_xticks=True,
58
58
  )
@@ -36,9 +36,10 @@ def _avg_ci_width(summary: pl.DataFrame, true_values: dict[str, float]) -> float
36
36
 
37
37
 
38
38
  def print_metrics():
39
+ base_summaries_dir = Path(os.environ["BELLA_LOG_SUMMARIES_DIR"])
39
40
  metrics = {}
40
41
  for name, scenario in SCENARIOS.items():
41
- summaries_dir = Path(os.environ["BELLA_LOG_SUMMARIES_DIR"]) / name
42
+ summaries_dir = base_summaries_dir / name
42
43
  summaries = {
43
44
  Path(log_summary).stem: pl.read_csv(log_summary)
44
45
  for log_summary in glob(str(summaries_dir / "*.csv"))
@@ -54,5 +55,5 @@ def print_metrics():
54
55
  }
55
56
  for target, true_values in scenario.targets.items()
56
57
  }
57
- with open("simulation-metrics.json", "w") as f:
58
+ with open(base_summaries_dir / "sim-metrics.json", "w") as f:
58
59
  json.dump(metrics, f)
@@ -89,9 +89,9 @@ SCENARIO = Scenario(
89
89
  features={
90
90
  f"{rate}Rate": {
91
91
  "timePredictor": Feature(is_binary=False, is_relevant=True),
92
- "randomPredictor": Feature(is_binary=False, is_relevant=False),
93
92
  "trait1Predictor": Feature(is_binary=True, is_relevant=True),
94
93
  "trait2Predictor": Feature(is_binary=True, is_relevant=False),
94
+ "randomPredictor": Feature(is_binary=False, is_relevant=False),
95
95
  }
96
96
  for rate in RATES
97
97
  },
@@ -0,0 +1,13 @@
1
+ <addon name='BELLA' version='0.0.1'>
2
+ <depends on="BEAST.base" atleast="2.7.0" atmost="2.7.9"/>
3
+ <depends on="BEAST.app" atleast="2.7.0" atmost="2.7.9"/>
4
+
5
+ <service type="beast.base.core.BEASTInterface">
6
+ <provider classname="bella.BayesMLP"/>
7
+ <provider classname="bella.ReLu"/>
8
+ <provider classname="bella.SoftPlus"/>
9
+ <provider classname="bella.Sigmoid"/>
10
+ <provider classname="bella.Tanh"/>
11
+ <provider classname="bella.SkylineNodeTreeLogger"/>
12
+ </service>
13
+ </addon>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bella-companion
3
- Version: 0.0.42
3
+ Version: 0.0.44
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -1,5 +1,7 @@
1
+ bella_companion/BELLA.jar,sha256=4mKDzPfz263rTqA9KS2f4Mc-UWGMuj8G48ZDonKSqVw,67408597
1
2
  bella_companion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- bella_companion/cli.py,sha256=0SwDxkDPqvsp36kGnrBMLPIhAQM8PIpNXrztZayqmDc,2409
3
+ bella_companion/cli.py,sha256=2Xa49zHn85UfgsJ-hxsVfacfZDMTQZG0JatEtkFBO6k,2796
4
+ bella_companion/version.xml,sha256=Gr3nsYqFhVNP0Mszl_IfilxefsPN8ZpQlGlB8OJSwnE,522
3
5
  bella_companion/eucovid/__init__.py,sha256=09Ld_G7fZvCDCgEWsmaOyLVQ8pFc9QHAGnXKJ9Zm2AM,81
4
6
  bella_companion/eucovid/run_beast.py,sha256=etaD_4SVdy_Pmz5s4jvDLzp2K_QV8leEY8Pe3xySBsk,3443
5
7
  bella_companion/eucovid/beast_configs/GLM.xml,sha256=b5rAeKVEam3u2AGSJsm7EHB6LcC0l9bp1SyZT2QyjpI,10892
@@ -33,7 +35,7 @@ bella_companion/simulations/__init__.py,sha256=ShYRdp1iSjnS_SzcsH-8jbqXz6P1nyRQZ
33
35
  bella_companion/simulations/features.py,sha256=DZOBpJGlQ0UinqUZYbEtoemZ2eQGVLV_i-DfpW31qJI,104
34
36
  bella_companion/simulations/generate_data.py,sha256=edfhXrs76hl30i_xizup4z6qgzXZyaDzX_PVC62Ytpw,849
35
37
  bella_companion/simulations/generate_figures.py,sha256=layMgoj3Bfl78Ceb1oE7YirAQ8zhjDyD9IrxDRXf6go,657
36
- bella_companion/simulations/metrics.py,sha256=duIkPb8cCXmIzjKA2yk9HLf4Y9eFIB_hRWaH05uIDws,1876
38
+ bella_companion/simulations/metrics.py,sha256=dg85Z5umewEzPXpfhQEEHtbQPCLT7LB0BEIPW8tAQYc,1934
37
39
  bella_companion/simulations/run_beast.py,sha256=qniy326i-vDCeHzzHpQRrSnY2ULqNNrO0z3GEsWx4Mc,3208
38
40
  bella_companion/simulations/summarize_logs.py,sha256=Shf3Dx9k4lTbmO__MSLw-aIA8a8kTCXhbctBcV6Izug,1216
39
41
  bella_companion/simulations/beast_configs/epi-multitype/GLM.xml,sha256=VymAYsaZVuB3EPE0DCQSXpKepVq8pPjKaB5yhEpaVkE,4334
@@ -48,29 +50,29 @@ bella_companion/simulations/beast_configs/fbd-2traits/Nonparametric.xml,sha256=e
48
50
  bella_companion/simulations/beast_configs/fbd-no-traits/GLM.xml,sha256=Caq7Gxqx-wYAu3_YkMikVqni3DjBv1Wt00sc1Upo1X8,4743
49
51
  bella_companion/simulations/beast_configs/fbd-no-traits/MLP.xml,sha256=JE_cGh2DW5yPAXyXXr0D3DlovmV-aIbze7qrhENHK3w,4275
50
52
  bella_companion/simulations/beast_configs/fbd-no-traits/Nonparametric.xml,sha256=m2xaHZwskCFInvVY1QH1fwQqH6p_fgESlPX2BbBeUhk,2822
51
- bella_companion/simulations/figures/__init__.py,sha256=aBYbJntH4egFmkSSWiVMYDEApXPYxJD7eA3TCPNNegM,658
52
- bella_companion/simulations/figures/epi_multitype_results.py,sha256=j85WgvN5AyAtX-CalMegr2lwlAZBmzyJxkikBPXRjCc,2629
53
- bella_companion/simulations/figures/epi_skyline_results.py,sha256=gI5Ha-OIEShcZLmqVuy0W8hJzkrsydQE-Coa65_BFCo,1667
54
- bella_companion/simulations/figures/fbd_2traits_results.py,sha256=JiXrbYkH1HwdJQhTHXj6KhMEXYgQmQ6LmDboAIO1CPA,2728
55
- bella_companion/simulations/figures/fbd_no_traits_results.py,sha256=fLsgpV3IbLLtxQEFNOL9K4jEEJrG324ziUM0rxIv7_k,1962
53
+ bella_companion/simulations/figures/__init__.py,sha256=LeHPeBb4vxJo0pxLZi_9s6iRBKvWC32yhAZBByqK2_8,590
54
+ bella_companion/simulations/figures/epi_multitype.py,sha256=j85WgvN5AyAtX-CalMegr2lwlAZBmzyJxkikBPXRjCc,2629
55
+ bella_companion/simulations/figures/epi_skyline.py,sha256=5wPGpQujxnSPasetM9lU07Or5ZC5j_h-LfVs6jdDzWc,1677
56
+ bella_companion/simulations/figures/fbd_2traits.py,sha256=JiXrbYkH1HwdJQhTHXj6KhMEXYgQmQ6LmDboAIO1CPA,2728
57
+ bella_companion/simulations/figures/fbd_no_traits.py,sha256=Hh2wDQFtk5nQTRSgApmtamn5xenWC5XhAlIk_xhOSII,1935
56
58
  bella_companion/simulations/figures/scenarios.py,sha256=gbMz1TUxxT2RSIq2kQlFioNdgSHk-gQY2OQuf6-7Fww,2817
57
59
  bella_companion/simulations/figures/utils.py,sha256=0M5OrxaEuqcj9rR2uAc_O7utQvhEceZGH0sKrGRWaWs,3129
58
60
  bella_companion/simulations/figures/explain/__init__.py,sha256=DnmVIWO65nTT5VsWnbS7NyYgKEY_eo4oMCtCY_ML2Vk,260
59
61
  bella_companion/simulations/figures/explain/pdp.py,sha256=3n3ssgufW_43pn2hO5V5J_jgcJH3Fpb8stIRtTnlQ8w,3801
60
- bella_companion/simulations/figures/explain/shap.py,sha256=qRfOMNwkU-hsBy5MHMTfVFAszaPESVOugCKQTVY8Q4Y,1940
62
+ bella_companion/simulations/figures/explain/shap.py,sha256=1PkbCgynbW-PXkkRpIcY7JoBYqOxqmu1OEOif_roFY8,2207
61
63
  bella_companion/simulations/scenarios/__init__.py,sha256=3Kl1lKcFpfb3vLX64DmSW4XCF5kXU1ZoHtstFH-ZIzU,876
62
64
  bella_companion/simulations/scenarios/common.py,sha256=_ddaSuTvEVdttGkXB4HPc2B7IB1F_GBOCW3cVOPZ-ZM,807
63
65
  bella_companion/simulations/scenarios/epi_multitype.py,sha256=fTkFeGHxyV_1f2nX3g_Oyr_e6wkorhXEicJjIAgeZKA,2439
64
66
  bella_companion/simulations/scenarios/epi_skyline.py,sha256=JqnOVATECxBUqEbkR5lBlMI2O8k4hO6ipR8k9cHUsm0,2365
65
- bella_companion/simulations/scenarios/fbd_2traits.py,sha256=5UmrDlxdCMWOF0v9_0c1Yh0TyaE_FKEdxhSzHNofwQY,3541
67
+ bella_companion/simulations/scenarios/fbd_2traits.py,sha256=-amB3NX0GsVgYbFuHH71t93FuXUEnRUyhWf2Qpcpia4,3541
66
68
  bella_companion/simulations/scenarios/fbd_no_traits.py,sha256=R6CH0fVeQg-Iesl39pq2uY8ICVEO4VZbvUVUCGwauJU,2520
67
69
  bella_companion/simulations/scenarios/scenario.py,sha256=_FRWAyOFbw94lAzd3zCD-1ek4TrssoiXfXRQPShLiIA,620
68
70
  bella_companion/utils/__init__.py,sha256=UtMwPK9dWf9NAl0ic8CSsgdW7aSm-5J49OqgvD7UpYw,480
69
71
  bella_companion/utils/beast.py,sha256=TBa0cLklX1_tXqoQE4LRYvds7mLg_9fS2-6U6OHENHo,2184
70
72
  bella_companion/utils/explain.py,sha256=uP7HPyn2YiykAI69BQV3RooDpC6qKoCLXfp3Uibp4zk,1475
71
73
  bella_companion/utils/slurm.py,sha256=xEyf-Jxk8fy71t3fko_Ic9WtUFSdLFE3w4tR17gaBPw,1868
72
- bella_companion-0.0.42.dist-info/METADATA,sha256=FY_Ja-RMCMyymPVti1WDLQLOtd5ie4rzWl3Zjj6ZJCg,347
73
- bella_companion-0.0.42.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
74
- bella_companion-0.0.42.dist-info/entry_points.txt,sha256=SVEYDBrkBWPrOGwnEH2aO5TSVIAvfKE37sqm-9ut9jg,51
75
- bella_companion-0.0.42.dist-info/top_level.txt,sha256=q0loZYv4vf3zF_tOATyAJqeyLOEuPyLbObNqIGP7Fmc,16
76
- bella_companion-0.0.42.dist-info/RECORD,,
74
+ bella_companion-0.0.44.dist-info/METADATA,sha256=yLCkFJaRBy303yaBpSoeoOOlzpPanoTybeG7PFr1sf0,347
75
+ bella_companion-0.0.44.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
76
+ bella_companion-0.0.44.dist-info/entry_points.txt,sha256=SVEYDBrkBWPrOGwnEH2aO5TSVIAvfKE37sqm-9ut9jg,51
77
+ bella_companion-0.0.44.dist-info/top_level.txt,sha256=q0loZYv4vf3zF_tOATyAJqeyLOEuPyLbObNqIGP7Fmc,16
78
+ bella_companion-0.0.44.dist-info/RECORD,,