simuci 0.1.5__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.
@@ -0,0 +1,86 @@
1
+ name: Upload Python Package
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ # ── 1. Build ────────────────────────────────────────────────
12
+ release-build:
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.13"
21
+
22
+ - name: Build release distributions
23
+ run: |
24
+ python -m pip install build
25
+ python -m build
26
+
27
+ - name: Upload distributions
28
+ uses: actions/upload-artifact@v4
29
+ with:
30
+ name: release-dists
31
+ path: dist/
32
+
33
+ # ── 2. Publish to TestPyPI ──────────────────────────────────
34
+ testpypi-publish:
35
+ runs-on: ubuntu-latest
36
+ needs:
37
+ - release-build
38
+ permissions:
39
+ # mandatory for trusted publishing
40
+ id-token: write
41
+ contents: read
42
+
43
+ environment:
44
+ name: testpypi
45
+ url: https://test.pypi.org/p/simuci
46
+
47
+ steps:
48
+ - name: Retrieve release distributions
49
+ uses: actions/download-artifact@v4
50
+ with:
51
+ name: release-dists
52
+ path: dist/
53
+
54
+ - name: Publish release distributions to TestPyPI
55
+ uses: pypa/gh-action-pypi-publish@release/v1
56
+ with:
57
+ repository-url: https://test.pypi.org/legacy/
58
+ packages-dir: dist/
59
+ verbose: true
60
+
61
+ # ── 3. Publish to PyPI (production) ────────────────────────
62
+ pypi-publish:
63
+ runs-on: ubuntu-latest
64
+ needs:
65
+ - testpypi-publish
66
+ permissions:
67
+ # mandatory for trusted publishing
68
+ id-token: write
69
+ contents: read
70
+
71
+ environment:
72
+ name: pypi
73
+ url: https://pypi.org/p/simuci
74
+
75
+ steps:
76
+ - name: Retrieve release distributions
77
+ uses: actions/download-artifact@v4
78
+ with:
79
+ name: release-dists
80
+ path: dist/
81
+
82
+ - name: Publish release distributions to PyPI
83
+ uses: pypa/gh-action-pypi-publish@release/v1
84
+ with:
85
+ packages-dir: dist/
86
+ verbose: true
@@ -0,0 +1,114 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+ MANIFEST
27
+
28
+ # PyInstaller
29
+ # Usually these files are written by a python script from a template
30
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .nox/
42
+ .coverage
43
+ .coverage.*
44
+ .cache
45
+ nosetests.xml
46
+ coverage.xml
47
+ *.cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+
51
+ # Translations
52
+ *.mo
53
+ *.pot
54
+
55
+ # Django stuff:
56
+ *.log
57
+ local_settings.py
58
+ db.sqlite3
59
+
60
+ # Flask stuff:
61
+ instance/
62
+ .webassets-cache
63
+
64
+ # Scrapy stuff:
65
+ .scrapy
66
+
67
+ # Sphinx documentation
68
+ docs/_build/
69
+
70
+ # PyBuilder
71
+ target/
72
+
73
+ # Jupyter Notebook
74
+ .ipynb_checkpoints
75
+
76
+ # IPython
77
+ profile_default/
78
+ ipython_config.py
79
+
80
+ # pyenv
81
+ .python-version
82
+
83
+ # celery beat schedule file
84
+ celerybeat-schedule
85
+
86
+ # SageMath parsed files
87
+ *.sage.py
88
+
89
+ # Environments
90
+ .env
91
+ .venv
92
+ env/
93
+ venv/
94
+ ENV/
95
+ env.bak/
96
+ venv.bak/
97
+
98
+ # Spyder project settings
99
+ .spyderproject
100
+ .spyproject
101
+
102
+ # Rope project settings
103
+ .ropeproject
104
+
105
+ # mkdocs documentation
106
+ /site
107
+
108
+ # mypy
109
+ .mypy_cache/
110
+ .dmypy.json
111
+ dmypy.json
112
+
113
+ # Pyre type checker
114
+ .pyre/
simuci-0.1.5/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SimUCI Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
simuci-0.1.5/PKG-INFO ADDED
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.4
2
+ Name: simuci
3
+ Version: 0.1.5
4
+ Summary: ICU discrete-event simulation engine — distribution sampling, patient clustering, and statistical validation.
5
+ Project-URL: Repository, https://github.com/coslatte/simuci
6
+ Author: SimUCI Team
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 SimUCI Team
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ License-File: LICENSE
29
+ Keywords: discrete-event,healthcare,icu,simpy,simulation
30
+ Classifier: Development Status :: 3 - Alpha
31
+ Classifier: Intended Audience :: Science/Research
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3.9
35
+ Classifier: Programming Language :: Python :: 3.10
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Classifier: Programming Language :: Python :: 3.13
39
+ Classifier: Programming Language :: Python :: 3.14
40
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
41
+ Classifier: Typing :: Typed
42
+ Requires-Python: <=3.14,>=3.9
43
+ Requires-Dist: numpy>=1.26
44
+ Requires-Dist: pandas>=2.0
45
+ Requires-Dist: scikit-learn>=1.3
46
+ Requires-Dist: scipy>=1.11
47
+ Requires-Dist: simpy>=4.0
48
+ Provides-Extra: dev
49
+ Requires-Dist: mypy>=1.10; extra == 'dev'
50
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
51
+ Requires-Dist: pytest>=8.0; extra == 'dev'
52
+ Requires-Dist: ruff>=0.4; extra == 'dev'
53
+ Description-Content-Type: text/markdown
54
+
55
+ # simuci
56
+
57
+ ICU discrete-event simulation engine — distribution sampling, patient clustering, and statistical validation.
58
+
59
+ ## Installation
60
+
61
+ ```bash
62
+ pip install simuci
63
+ ```
64
+
65
+ For development:
66
+
67
+ ```bash
68
+ git clone https://github.com/coslatte/simuci.git
69
+ cd simuci
70
+ pip install -e ".[dev]"
71
+ ```
72
+
73
+ ## Quick Start
74
+
75
+ ```python
76
+ from simuci import Experiment, single_run, multiple_replication
77
+
78
+ # Create an experiment with patient parameters
79
+ exp = Experiment(
80
+ age=55,
81
+ diagnosis_admission1=11,
82
+ diagnosis_admission2=0,
83
+ diagnosis_admission3=0,
84
+ diagnosis_admission4=0,
85
+ apache=20,
86
+ respiratory_insufficiency=5,
87
+ artificial_ventilation=1,
88
+ uti_stay=100,
89
+ vam_time=50,
90
+ preuti_stay_time=10,
91
+ percent=3,
92
+ )
93
+
94
+ # Single replication (requires centroids CSV)
95
+ result = single_run(exp, centroids_path="path/to/centroids.csv")
96
+ print(result)
97
+ # {'Tiempo Pre VAM': 5, 'Tiempo VAM': 89, 'Tiempo Post VAM': 168, 'Estadia UCI': 262, 'Estadia Post UCI': 45}
98
+
99
+ # Multiple replications → DataFrame
100
+ df = multiple_replication(exp, n_reps=200, centroids_path="path/to/centroids.csv")
101
+ print(df.describe())
102
+ ```
103
+
104
+ ## Using Your Own Centroid Data
105
+
106
+ You must pass the path to your centroid CSV explicitly:
107
+
108
+ ```python
109
+ from simuci import single_run, Experiment
110
+
111
+ exp = Experiment(age=55, ..., validate=False)
112
+
113
+ # Point to your centroids CSV
114
+ result = single_run(exp, centroids_path="path/to/real_centroids.csv")
115
+ ```
116
+
117
+ The centroids CSV must have:
118
+
119
+ - An index column (cluster IDs: 0, 1, 2)
120
+ - At least 11 numeric columns (features used for nearest-centroid classification)
121
+
122
+ You can also use the loader directly:
123
+
124
+ ```python
125
+ from simuci.loaders import CentroidLoader
126
+
127
+ loader = CentroidLoader()
128
+ centroids = loader.load("path/to/centroids.csv") # returns numpy array
129
+ ```
130
+
131
+ ## Statistical Validation
132
+
133
+ ```python
134
+ import numpy as np
135
+ from simuci import SimulationMetrics, Wilcoxon, Friedman
136
+
137
+ # Compare simulation output to real data
138
+ metrics = SimulationMetrics(
139
+ true_data=np.array(...), # (n_patients, n_variables)
140
+ simulation_data=np.array(...), # (n_patients, n_replicates, n_variables)
141
+ )
142
+ metrics.evaluate(confidence_level=0.95, result_as_dict=True)
143
+
144
+ print(metrics.coverage_percentage)
145
+ print(metrics.error_margin)
146
+ print(metrics.kolmogorov_smirnov_result)
147
+ print(metrics.anderson_darling_result)
148
+ ```
149
+
150
+ ## Input Validation
151
+
152
+ All `Experiment` inputs are validated on construction by default:
153
+
154
+ ```python
155
+ from simuci import Experiment
156
+
157
+ # This raises ValueError: age must be between 14 and 100
158
+ Experiment(age=200, ...)
159
+ ```
160
+
161
+ Skip validation with `validate=False` if you've already validated externally.
162
+
163
+ ## API Reference
164
+
165
+ | Symbol | Description |
166
+ |--------|-------------|
167
+ | `Experiment` | Patient parameters + result container |
168
+ | `single_run(exp)` | One simulation replication |
169
+ | `multiple_replication(exp, n_reps)` | N replications → DataFrame |
170
+ | `clustering(edad, ...)` | Nearest-centroid patient classifier |
171
+ | `Wilcoxon` | Paired Wilcoxon signed-rank test |
172
+ | `Friedman` | Friedman chi-square test |
173
+ | `SimulationMetrics` | Full evaluation suite (coverage, RMSE, KS, AD) |
174
+ | `StatsUtils` | Static CI helper |
175
+ | `CentroidLoader` | CSV loader with schema validation |
176
+ | `validate_experiment_inputs()` | Parameter range checking |
177
+
178
+ ## License
179
+
180
+ MIT
simuci-0.1.5/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # simuci
2
+
3
+ ICU discrete-event simulation engine — distribution sampling, patient clustering, and statistical validation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install simuci
9
+ ```
10
+
11
+ For development:
12
+
13
+ ```bash
14
+ git clone https://github.com/coslatte/simuci.git
15
+ cd simuci
16
+ pip install -e ".[dev]"
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```python
22
+ from simuci import Experiment, single_run, multiple_replication
23
+
24
+ # Create an experiment with patient parameters
25
+ exp = Experiment(
26
+ age=55,
27
+ diagnosis_admission1=11,
28
+ diagnosis_admission2=0,
29
+ diagnosis_admission3=0,
30
+ diagnosis_admission4=0,
31
+ apache=20,
32
+ respiratory_insufficiency=5,
33
+ artificial_ventilation=1,
34
+ uti_stay=100,
35
+ vam_time=50,
36
+ preuti_stay_time=10,
37
+ percent=3,
38
+ )
39
+
40
+ # Single replication (requires centroids CSV)
41
+ result = single_run(exp, centroids_path="path/to/centroids.csv")
42
+ print(result)
43
+ # {'Tiempo Pre VAM': 5, 'Tiempo VAM': 89, 'Tiempo Post VAM': 168, 'Estadia UCI': 262, 'Estadia Post UCI': 45}
44
+
45
+ # Multiple replications → DataFrame
46
+ df = multiple_replication(exp, n_reps=200, centroids_path="path/to/centroids.csv")
47
+ print(df.describe())
48
+ ```
49
+
50
+ ## Using Your Own Centroid Data
51
+
52
+ You must pass the path to your centroid CSV explicitly:
53
+
54
+ ```python
55
+ from simuci import single_run, Experiment
56
+
57
+ exp = Experiment(age=55, ..., validate=False)
58
+
59
+ # Point to your centroids CSV
60
+ result = single_run(exp, centroids_path="path/to/real_centroids.csv")
61
+ ```
62
+
63
+ The centroids CSV must have:
64
+
65
+ - An index column (cluster IDs: 0, 1, 2)
66
+ - At least 11 numeric columns (features used for nearest-centroid classification)
67
+
68
+ You can also use the loader directly:
69
+
70
+ ```python
71
+ from simuci.loaders import CentroidLoader
72
+
73
+ loader = CentroidLoader()
74
+ centroids = loader.load("path/to/centroids.csv") # returns numpy array
75
+ ```
76
+
77
+ ## Statistical Validation
78
+
79
+ ```python
80
+ import numpy as np
81
+ from simuci import SimulationMetrics, Wilcoxon, Friedman
82
+
83
+ # Compare simulation output to real data
84
+ metrics = SimulationMetrics(
85
+ true_data=np.array(...), # (n_patients, n_variables)
86
+ simulation_data=np.array(...), # (n_patients, n_replicates, n_variables)
87
+ )
88
+ metrics.evaluate(confidence_level=0.95, result_as_dict=True)
89
+
90
+ print(metrics.coverage_percentage)
91
+ print(metrics.error_margin)
92
+ print(metrics.kolmogorov_smirnov_result)
93
+ print(metrics.anderson_darling_result)
94
+ ```
95
+
96
+ ## Input Validation
97
+
98
+ All `Experiment` inputs are validated on construction by default:
99
+
100
+ ```python
101
+ from simuci import Experiment
102
+
103
+ # This raises ValueError: age must be between 14 and 100
104
+ Experiment(age=200, ...)
105
+ ```
106
+
107
+ Skip validation with `validate=False` if you've already validated externally.
108
+
109
+ ## API Reference
110
+
111
+ | Symbol | Description |
112
+ |--------|-------------|
113
+ | `Experiment` | Patient parameters + result container |
114
+ | `single_run(exp)` | One simulation replication |
115
+ | `multiple_replication(exp, n_reps)` | N replications → DataFrame |
116
+ | `clustering(edad, ...)` | Nearest-centroid patient classifier |
117
+ | `Wilcoxon` | Paired Wilcoxon signed-rank test |
118
+ | `Friedman` | Friedman chi-square test |
119
+ | `SimulationMetrics` | Full evaluation suite (coverage, RMSE, KS, AD) |
120
+ | `StatsUtils` | Static CI helper |
121
+ | `CentroidLoader` | CSV loader with schema validation |
122
+ | `validate_experiment_inputs()` | Parameter range checking |
123
+
124
+ ## License
125
+
126
+ MIT
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "simuci"
7
+ version = "0.1.5"
8
+ description = "ICU discrete-event simulation engine — distribution sampling, patient clustering, and statistical validation."
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ requires-python = ">=3.9, <=3.14"
12
+ authors = [{ name = "SimUCI Team" }]
13
+ keywords = ["icu", "simulation", "discrete-event", "simpy", "healthcare"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Science/Research",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Topic :: Scientific/Engineering :: Medical Science Apps.",
26
+ "Typing :: Typed",
27
+ ]
28
+
29
+ dependencies = [
30
+ "numpy>=1.26",
31
+ "pandas>=2.0",
32
+ "scipy>=1.11",
33
+ "simpy>=4.0",
34
+ "scikit-learn>=1.3",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest>=8.0",
40
+ "pytest-cov>=5.0",
41
+ "mypy>=1.10",
42
+ "ruff>=0.4",
43
+ ]
44
+
45
+ [project.urls]
46
+ Repository = "https://github.com/coslatte/simuci"
47
+
48
+ [tool.hatch.build.targets.wheel]
49
+ packages = ["src/simuci"]
50
+
51
+ [tool.ruff]
52
+ target-version = "py311"
53
+ line-length = 120
54
+
55
+ [tool.ruff.lint]
56
+ select = ["E", "F", "W", "I", "UP", "B", "SIM"]
57
+
58
+ [tool.mypy]
59
+ python_version = "3.11"
60
+ strict = true
61
+ warn_return_any = true
62
+ warn_unused_configs = true
63
+
64
+ [tool.pytest.ini_options]
65
+ testpaths = ["tests"]
66
+
@@ -0,0 +1,58 @@
1
+ """simuci — ICU discrete-event simulation engine.
2
+
3
+ Public API
4
+ ----------
5
+ Core simulation:
6
+ Experiment, single_run, multiple_replication, Simulation
7
+
8
+ Clustering & distributions:
9
+ clustering, clear_centroid_cache
10
+
11
+ Statistical validation:
12
+ Wilcoxon, Friedman, SimulationMetrics, StatsUtils
13
+
14
+ Input validation:
15
+ validate_experiment_inputs, validate_simulation_runs
16
+
17
+ Data loading:
18
+ CentroidLoader
19
+
20
+ CSV utilities:
21
+ process_data (sub-module)
22
+ """
23
+
24
+ from __future__ import annotations
25
+
26
+ from simuci.distributions import clear_centroid_cache, clustering
27
+ from simuci.experiment import Experiment, multiple_replication, single_run
28
+ from simuci.loaders import CentroidLoader
29
+ from simuci.simulation import Simulation
30
+ from simuci.stats import Friedman, SimulationMetrics, StatsUtils, Wilcoxon
31
+ from simuci.validators import validate_experiment_inputs, validate_simulation_runs
32
+
33
+ __version__ = "0.1.0"
34
+
35
+ __all__ = [
36
+ # Core
37
+ "Experiment",
38
+ "Simulation",
39
+ "single_run",
40
+ "multiple_replication",
41
+
42
+ # Clustering
43
+ "clustering",
44
+ "clear_centroid_cache",
45
+
46
+ # Statistics
47
+ "Wilcoxon",
48
+ "Friedman",
49
+ "SimulationMetrics",
50
+ "StatsUtils",
51
+
52
+ # Validation
53
+ "validate_experiment_inputs",
54
+ "validate_simulation_runs",
55
+
56
+ # Loaders
57
+ "CentroidLoader",
58
+ ]