medpipe 0.1.2__tar.gz → 0.2.2.dev0__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 (44) hide show
  1. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/PKG-INFO +7 -2
  2. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/README.md +5 -1
  3. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/pyproject.toml +1 -1
  4. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/requirements.txt +1 -0
  5. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/models/core.py +12 -2
  6. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe.egg-info/PKG-INFO +7 -2
  7. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe.egg-info/requires.txt +1 -0
  8. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_models_core.py +15 -28
  9. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_pipeline_Pipeline.py +49 -1
  10. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/LICENSE +0 -0
  11. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/setup.cfg +0 -0
  12. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/__init__.py +0 -0
  13. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/Preprocessor.py +0 -0
  14. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/__init__.py +0 -0
  15. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/db.py +0 -0
  16. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/preprocessing.py +0 -0
  17. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/sampler.py +0 -0
  18. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/weighting.py +0 -0
  19. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/metrics/__init__.py +0 -0
  20. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/metrics/core.py +0 -0
  21. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/metrics/plots.py +0 -0
  22. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/models/Calibrator.py +0 -0
  23. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/models/Predictor.py +0 -0
  24. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/models/__init__.py +0 -0
  25. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/pipeline/Pipeline.py +0 -0
  26. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/pipeline/__init__.py +0 -0
  27. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/utils/__init__.py +0 -0
  28. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/utils/config.py +0 -0
  29. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/utils/exceptions.py +0 -0
  30. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/utils/io.py +0 -0
  31. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/utils/logger.py +0 -0
  32. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe.egg-info/SOURCES.txt +0 -0
  33. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe.egg-info/dependency_links.txt +0 -0
  34. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe.egg-info/top_level.txt +0 -0
  35. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_data_Preprocessor.py +0 -0
  36. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_data_db.py +0 -0
  37. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_data_preprocessing.py +0 -0
  38. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_data_sampler.py +0 -0
  39. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_data_weighting.py +0 -0
  40. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_metrics_core.py +0 -0
  41. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_utils_config.py +0 -0
  42. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_utils_exceptions.py +0 -0
  43. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_utils_io.py +0 -0
  44. {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_utils_logger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: medpipe
3
- Version: 0.1.2
3
+ Version: 0.2.2.dev0
4
4
  Summary: A package for clinical AI pipeline development
5
5
  Author-email: Mathias Roesler <mathias.roesler@auckland.co.nz>
6
6
  License-Expression: Apache-2.0
@@ -22,6 +22,7 @@ Requires-Dist: pytest==9.0.1
22
22
  Requires-Dist: scikit_learn==1.8.0
23
23
  Requires-Dist: scipy==1.17.0
24
24
  Requires-Dist: pyarrow==23.0.1
25
+ Requires-Dist: lightgbm==4.6.0
25
26
  Dynamic: license-file
26
27
 
27
28
  # medpipe
@@ -45,7 +46,11 @@ The **medpipe** package is a layer to help create AI models for clinical applica
45
46
  ___
46
47
  ## Installation
47
48
 
48
- To install **medpipe** clone the GitHub repository and install the package with pip:
49
+ To install **medpipe** from the PyPI use pip:
50
+ ```
51
+ $ pip install medpipe
52
+ ```
53
+ or clone the GitHub repository and install the package with pip:
49
54
  ```
50
55
  $ git clone git@github.com:Surgical-Recovery-and-Safety-Lab/medpipe.git
51
56
  $ cd medpipe
@@ -19,7 +19,11 @@ The **medpipe** package is a layer to help create AI models for clinical applica
19
19
  ___
20
20
  ## Installation
21
21
 
22
- To install **medpipe** clone the GitHub repository and install the package with pip:
22
+ To install **medpipe** from the PyPI use pip:
23
+ ```
24
+ $ pip install medpipe
25
+ ```
26
+ or clone the GitHub repository and install the package with pip:
23
27
  ```
24
28
  $ git clone git@github.com:Surgical-Recovery-and-Safety-Lab/medpipe.git
25
29
  $ cd medpipe
@@ -4,7 +4,7 @@ requires = [ "setuptools>=80.9" ]
4
4
 
5
5
  [project]
6
6
  name = "medpipe"
7
- version = "0.1.2"
7
+ version = "0.2.2.dev0"
8
8
  description = "A package for clinical AI pipeline development"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -7,3 +7,4 @@ pytest==9.0.1
7
7
  scikit_learn==1.8.0
8
8
  scipy==1.17.0
9
9
  pyarrow==23.0.1
10
+ lightgbm==4.6.0
@@ -14,6 +14,7 @@ Functions:
14
14
 
15
15
  import joblib
16
16
  import numpy as np
17
+ from lightgbm import LGBMClassifier
17
18
  from sklearn.ensemble import HistGradientBoostingClassifier
18
19
  from sklearn.isotonic import IsotonicRegression
19
20
  from sklearn.linear_model import LogisticRegression
@@ -36,9 +37,10 @@ def create_model(
36
37
 
37
38
  Parameters
38
39
  ----------
39
- model_type : {"hgb-c", "logistic", "isotonic"}
40
+ model_type : {"hgb-c", "lgbm-c", "logistic", "isotonic"}
40
41
  Type of model to create.
41
42
  hgb-c: histogram gradient boosting classifier.
43
+ lgbm-c: LightGBM classifier.
42
44
  logistic: logistic regression.
43
45
  isotonic: isotonic regression.
44
46
  quiet : bool, default: False
@@ -48,7 +50,7 @@ def create_model(
48
50
 
49
51
  Returns
50
52
  -------
51
- model : HistGradBoostingClassifier
53
+ model : HistGradBoostingClassifier, LGBMClassifier
52
54
  LogisticRegression, IsotonicRegression,
53
55
  Created model.
54
56
 
@@ -73,6 +75,14 @@ def create_model(
73
75
  SCRIPT_NAME,
74
76
  )
75
77
  model = HistGradientBoostingClassifier(**config_params)
78
+ case "lgbm-c":
79
+ if not quiet:
80
+ print_message(
81
+ "Creating a LGBMClassifier",
82
+ logger,
83
+ SCRIPT_NAME,
84
+ )
85
+ model = LGBMClassifier(**config_params)
76
86
  case "logistic":
77
87
  if not quiet:
78
88
  print_message(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: medpipe
3
- Version: 0.1.2
3
+ Version: 0.2.2.dev0
4
4
  Summary: A package for clinical AI pipeline development
5
5
  Author-email: Mathias Roesler <mathias.roesler@auckland.co.nz>
6
6
  License-Expression: Apache-2.0
@@ -22,6 +22,7 @@ Requires-Dist: pytest==9.0.1
22
22
  Requires-Dist: scikit_learn==1.8.0
23
23
  Requires-Dist: scipy==1.17.0
24
24
  Requires-Dist: pyarrow==23.0.1
25
+ Requires-Dist: lightgbm==4.6.0
25
26
  Dynamic: license-file
26
27
 
27
28
  # medpipe
@@ -45,7 +46,11 @@ The **medpipe** package is a layer to help create AI models for clinical applica
45
46
  ___
46
47
  ## Installation
47
48
 
48
- To install **medpipe** clone the GitHub repository and install the package with pip:
49
+ To install **medpipe** from the PyPI use pip:
50
+ ```
51
+ $ pip install medpipe
52
+ ```
53
+ or clone the GitHub repository and install the package with pip:
49
54
  ```
50
55
  $ git clone git@github.com:Surgical-Recovery-and-Safety-Lab/medpipe.git
51
56
  $ cd medpipe
@@ -7,3 +7,4 @@ pytest==9.0.1
7
7
  scikit_learn==1.8.0
8
8
  scipy==1.17.0
9
9
  pyarrow==23.0.1
10
+ lightgbm==4.6.0
@@ -9,7 +9,10 @@ Test functions for the models.core module
9
9
  import pathlib
10
10
 
11
11
  import pytest
12
+ from lightgbm import LGBMClassifier
12
13
  from sklearn.ensemble import HistGradientBoostingClassifier
14
+ from sklearn.isotonic import IsotonicRegression
15
+ from sklearn.linear_model import LogisticRegression
13
16
 
14
17
  from medpipe.models.core import create_model
15
18
  from medpipe.utils.config import get_configuration, split_version_number
@@ -20,10 +23,17 @@ DATA_DIR = CWD / "test/test_data/"
20
23
 
21
24
 
22
25
  @pytest.mark.parametrize(
23
- "model_type, config_file",
24
- [("hgb-c", "config/HGBc_config.toml"), ("hgb-c", "")],
26
+ "model_type, config_file, model_class",
27
+ [
28
+ ("hgb-c", "config/HGBc_config.toml", HistGradientBoostingClassifier),
29
+ ("hgb-c", "", HistGradientBoostingClassifier),
30
+ ("isotonic", "", IsotonicRegression),
31
+ ("logistic", "", LogisticRegression),
32
+ ("lgbm-c", "config/LGBMc_config.toml", LGBMClassifier),
33
+ ("lgbm-c", "", LGBMClassifier),
34
+ ],
25
35
  )
26
- def test_create_model_HGBc_success(model_type, config_file):
36
+ def test_create_model_success(model_type, config_file, model_class):
27
37
  if config_file:
28
38
  general_params = read_toml_configuration(str(DATA_DIR / config_file))
29
39
  _, model_version = split_version_number(general_params["version"])
@@ -39,13 +49,7 @@ def test_create_model_HGBc_success(model_type, config_file):
39
49
  else:
40
50
  model = create_model(model_type, logger=None)
41
51
 
42
- if model_type == "hgb-c":
43
- assert isinstance(model, HistGradientBoostingClassifier)
44
-
45
-
46
- def test_create_model_not_valid_model():
47
- with pytest.raises(ValueError):
48
- create_model("not_valid_model")
52
+ assert isinstance(model, model_class)
49
53
 
50
54
 
51
55
  @pytest.mark.parametrize("model_type", [123, [], {}, 1.5, None])
@@ -55,7 +59,7 @@ def test_create_model_invalid_model_type(model_type):
55
59
 
56
60
 
57
61
  # Test invalid configuration parameters for the model
58
- @pytest.mark.parametrize("model_type", ["hgb-c"])
62
+ @pytest.mark.parametrize("model_type", ["hgb-c", "isotonic", "logistic"])
59
63
  def test_create_model_invalid_config(model_type):
60
64
  model_config = {"invalid": None}
61
65
  # Expecting a failure due to invalid config
@@ -65,20 +69,3 @@ def test_create_model_invalid_config(model_type):
65
69
  logger=None,
66
70
  **model_config,
67
71
  )
68
-
69
-
70
- # Test passing a logger to see if log messages are printed
71
- @pytest.mark.parametrize("model_type", ["hgb-c"])
72
- def test_create_model_with_logger(model_type):
73
- # Here we'll check if logger prints the expected message to stdout/stderr
74
- logger = None # Use a mock or None for simplicity in this case
75
- create_model(model_type, logger=logger)
76
-
77
-
78
- # Test `create_model` when no config file is passed
79
- @pytest.mark.parametrize("model_type", ["hgb-c"])
80
- def test_create_model_without_config(model_type):
81
- model = create_model(model_type, logger=None)
82
-
83
- if model_type == "hgb-c":
84
- assert isinstance(model, HistGradientBoostingClassifier)
@@ -19,7 +19,7 @@ DATA_DIR = CWD / "test/test_data/"
19
19
 
20
20
  @pytest.mark.parametrize(
21
21
  "config_file",
22
- ["config/HGBc_config.toml"],
22
+ ["config/HGBc_config.toml", "config/LGBMc_config.toml"],
23
23
  )
24
24
  def test_create_Pipeline_success(config_file):
25
25
  general_config = read_toml_configuration(str(DATA_DIR / config_file))
@@ -50,6 +50,30 @@ def test_run_Pipeline_HGBc_single_label(version_number):
50
50
  pipeline.run(X_train)
51
51
 
52
52
 
53
+ @pytest.mark.parametrize(
54
+ "version_number",
55
+ [
56
+ "v0.1.1.2-a.1.0.1",
57
+ "v0.1.0.2-a.2.1.1",
58
+ "v0.1.1.2-a.3.2.1",
59
+ "v0.1.0.2-a.4.0.1",
60
+ "v0.1.0.2-a.5.1.1",
61
+ "v0.1.2.2-a.1.1.1",
62
+ "v0.1.3.2-a.2.1.1",
63
+ ],
64
+ )
65
+ def test_run_Pipeline_LGBMc_single_label(version_number):
66
+ config_file = "config/LGBMc_config.toml"
67
+ data = load_data_from_csv("test/test_data/test_data.csv")
68
+ general_config = read_toml_configuration(str(DATA_DIR / config_file))
69
+ general_config["version"] = version_number
70
+ pipeline = Pipeline(general_config)
71
+
72
+ pipeline.preprocessor.fit(data)
73
+ X_train, _ = pipeline.get_test_data(data)
74
+ pipeline.run(X_train)
75
+
76
+
53
77
  @pytest.mark.parametrize(
54
78
  "version_number",
55
79
  [
@@ -72,3 +96,27 @@ def test_run_Pipeline_HGBc_multi_label(version_number):
72
96
  pipeline.preprocessor.fit(data)
73
97
  X_train, _ = pipeline.get_test_data(data)
74
98
  pipeline.run(X_train)
99
+
100
+
101
+ @pytest.mark.parametrize(
102
+ "version_number",
103
+ [
104
+ "v0.1.1.2-b.1.0.1",
105
+ "v0.1.0.2-b.2.1.1",
106
+ "v0.1.1.2-b.3.2.1",
107
+ "v0.1.0.2-b.4.0.1",
108
+ "v0.1.0.2-b.5.1.1",
109
+ "v0.1.2.2-b.5.1.1",
110
+ "v0.1.3.2-b.2.1.1",
111
+ ],
112
+ )
113
+ def test_run_Pipeline_LGBMc_multi_label(version_number):
114
+ config_file = "config/LGBMc_config.toml"
115
+ data = load_data_from_csv("test/test_data/test_data.csv")
116
+ general_config = read_toml_configuration(str(DATA_DIR / config_file))
117
+ general_config["version"] = version_number
118
+ pipeline = Pipeline(general_config)
119
+
120
+ pipeline.preprocessor.fit(data)
121
+ X_train, _ = pipeline.get_test_data(data)
122
+ pipeline.run(X_train)
File without changes
File without changes