Skip to main content

ICU discrete-event simulation engine — distribution sampling, patient clustering, and statistical validation.

Project description

simuci

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.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

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simuci-0.1.5.tar.gz (62.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simuci-0.1.5-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file simuci-0.1.5.tar.gz.

File metadata

  • Download URL: simuci-0.1.5.tar.gz
  • Upload date:
  • Size: 62.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for simuci-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9c24f112ae24faa34bb828b94281552ef1b4553b98b07406bd23b8d3c8e2e997
MD5 06a1b06dddbf3c30e886a9fc29125676
BLAKE2b-256 588f8fc628583fb86f86f37b75844388b04523043f9d37df401b79311ad8fa9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for simuci-0.1.5.tar.gz:

Publisher: python-publish.yml on coslatte/simuci

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simuci-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: simuci-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for simuci-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 64d3f654c149679f109bd8f0fe342954be3097d2c20fd71a021191acd213a610
MD5 6d73415ede7c20679128b912c1db44ee
BLAKE2b-256 e199f892198d1c5185a64f3c77a0a954a06f9e433aee460339e0420cc011cdca

See more details on using hashes here.

Provenance

The following attestation bundles were made for simuci-0.1.5-py3-none-any.whl:

Publisher: python-publish.yml on coslatte/simuci

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page