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.
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/PKG-INFO +7 -2
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/README.md +5 -1
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/pyproject.toml +1 -1
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/requirements.txt +1 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/models/core.py +12 -2
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe.egg-info/PKG-INFO +7 -2
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe.egg-info/requires.txt +1 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_models_core.py +15 -28
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_pipeline_Pipeline.py +49 -1
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/LICENSE +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/setup.cfg +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/__init__.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/Preprocessor.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/__init__.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/db.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/preprocessing.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/sampler.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/data/weighting.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/metrics/__init__.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/metrics/core.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/metrics/plots.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/models/Calibrator.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/models/Predictor.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/models/__init__.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/pipeline/Pipeline.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/pipeline/__init__.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/utils/__init__.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/utils/config.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/utils/exceptions.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/utils/io.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe/utils/logger.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe.egg-info/SOURCES.txt +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe.egg-info/dependency_links.txt +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/src/medpipe.egg-info/top_level.txt +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_data_Preprocessor.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_data_db.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_data_preprocessing.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_data_sampler.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_data_weighting.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_metrics_core.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_utils_config.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_utils_exceptions.py +0 -0
- {medpipe-0.1.2 → medpipe-0.2.2.dev0}/test/test_utils_io.py +0 -0
- {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.
|
|
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**
|
|
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**
|
|
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
|
|
@@ -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.
|
|
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**
|
|
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
|
|
@@ -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
|
-
[
|
|
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
|
|
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
|
-
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|