ICU discrete-event simulation engine — distribution sampling, patient clustering, and statistical validation.
Project description
simuci
🇪🇸 Español: Léeme en español
ICU discrete-event simulation engine — distribution sampling, patient clustering, and statistical validation.
Installation
pip install simuci
For development:
git clone https://github.com/coslatte/simuci.git
cd simuci
pip install -e ".[dev]"
Quick Start
from simuci import Experiment, single_run, multiple_replication
# Create an experiment with patient parameters
exp = Experiment(
age=55,
diagnosis_admission1=11,
diagnosis_admission2=0,
diagnosis_admission3=0,
diagnosis_admission4=0,
apache=20,
respiratory_insufficiency=5,
artificial_ventilation=1,
uti_stay=100,
vam_time=50,
preuti_stay_time=10,
percent=3,
)
# Single replication (requires centroids CSV)
result = single_run(exp, centroids_path="path/to/centroids.csv")
print(result)
# {'Tiempo Pre VAM': 5, 'Tiempo VAM': 89, 'Tiempo Post VAM': 168, 'Estadia UCI': 262, 'Estadia Post UCI': 45}
# Multiple replications → DataFrame
df = multiple_replication(exp, n_reps=200, centroids_path="path/to/centroids.csv")
print(df.describe())
Using Your Own Centroid Data
You must pass the path to your centroid CSV explicitly:
from simuci import single_run, Experiment
exp = Experiment(age=55, ..., validate=False)
# Point to your centroids CSV
result = single_run(exp, centroids_path="path/to/real_centroids.csv")
The centroids CSV must have:
- An index column (cluster IDs: 0, 1, 2)
- At least 11 numeric columns (features used for nearest-centroid classification)
You can also use the loader directly:
from simuci.io.loaders import CentroidLoader
loader = CentroidLoader()
centroids = loader.load("path/to/centroids.csv") # returns numpy array
Statistical Validation
import numpy as np
from simuci import SimulationMetrics, Wilcoxon, Friedman
# Compare simulation output to real data
metrics = SimulationMetrics(
true_data=np.array(...), # (n_patients, n_variables)
simulation_data=np.array(...), # (n_patients, n_replicates, n_variables)
)
metrics.evaluate(confidence_level=0.95, result_as_dict=True)
print(metrics.coverage_percentage)
print(metrics.error_margin)
print(metrics.kolmogorov_smirnov_result)
print(metrics.anderson_darling_result)
Input Validation
All Experiment inputs are validated on construction by default:
from simuci import Experiment
# This raises ValueError: age must be between 14 and 100
Experiment(age=200, ...)
Skip validation with validate=False if you've already validated externally.
API Reference
| Symbol | Description |
|---|---|
Experiment |
Patient parameters + result container |
single_run(exp) |
One simulation replication |
multiple_replication(exp, n_reps) |
N replications → DataFrame |
clustering(edad, ...) |
Nearest-centroid patient classifier |
Wilcoxon |
Paired Wilcoxon signed-rank test |
Friedman |
Friedman chi-square test |
SimulationMetrics |
Full evaluation suite (coverage, RMSE, KS, AD) |
StatsUtils |
Static CI helper |
CentroidLoader |
CSV loader with schema validation |
validate_experiment_inputs() |
Parameter range checking |
Architecture
Project map (core vs. validation, I/O, statistics, tooling): docs/architecture.md
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simuci-1.0.1.tar.gz.
File metadata
- Download URL: simuci-1.0.1.tar.gz
- Upload date:
- Size: 90.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
379011ab44bcfc690182c0bcf4ce01a1cfe3e4c17e1bbdf553e631d0892fea3b
|
|
| MD5 |
7624f5bd6cf1696f509b665fcdc6fd6e
|
|
| BLAKE2b-256 |
e60c1297711530b1f4dd3967861f1a4fac712044b506fc2b7a6b56f8e9dc5f90
|
Provenance
The following attestation bundles were made for simuci-1.0.1.tar.gz:
Publisher:
python-publish.yml on coslatte/simuci
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simuci-1.0.1.tar.gz -
Subject digest:
379011ab44bcfc690182c0bcf4ce01a1cfe3e4c17e1bbdf553e631d0892fea3b - Sigstore transparency entry: 949360745
- Sigstore integration time:
-
Permalink:
coslatte/simuci@8e06a55b7a5d37e041f461acfa0f8bdf725246b1 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/coslatte
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8e06a55b7a5d37e041f461acfa0f8bdf725246b1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file simuci-1.0.1-py3-none-any.whl.
File metadata
- Download URL: simuci-1.0.1-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b590329e0213a74a7b13ca10ae9ec34c92062593ad94a354b0c6f80735ae3de
|
|
| MD5 |
9ad8c98e172156bda665c6734443649f
|
|
| BLAKE2b-256 |
535e19c2d295188bdcbac8897b3fb9a6c45dbff6664abd30afc98b6ae1889565
|
Provenance
The following attestation bundles were made for simuci-1.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on coslatte/simuci
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simuci-1.0.1-py3-none-any.whl -
Subject digest:
9b590329e0213a74a7b13ca10ae9ec34c92062593ad94a354b0c6f80735ae3de - Sigstore transparency entry: 949360794
- Sigstore integration time:
-
Permalink:
coslatte/simuci@8e06a55b7a5d37e041f461acfa0f8bdf725246b1 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/coslatte
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@8e06a55b7a5d37e041f461acfa0f8bdf725246b1 -
Trigger Event:
release
-
Statement type: