Skip to main content

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


Download files

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

Source Distribution

simuci-1.0.0.tar.gz (91.0 kB view details)

Uploaded Source

Built Distribution

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

simuci-1.0.0-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for simuci-1.0.0.tar.gz
Algorithm Hash digest
SHA256 359e93b86c2daaf94e595db95629bbf99d5158c522c65e7a0422715d5ef22bd2
MD5 b4e2c36b9bf9befdf7d7ab9118d77bcb
BLAKE2b-256 04d8edfa52eeb6f517420b392ca95c13d52168394ec18cf5a84bc6d16525f4f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for simuci-1.0.0.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-1.0.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for simuci-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c4c279d3c9988f24c88449026b6d62405161db232e529077fdf9bc6c9699863
MD5 cde6f3794657219423d2480a9664b3bb
BLAKE2b-256 c2af243502fff116825b679709449dfc9e97a193d36086a10d3f13589b928f0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for simuci-1.0.0-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