Package: yaib
🧪 Yet Another ICU BenchmarkYet another ICU benchmark (YAIB) provides a framework for doing clinical machine learning experiments on Intensive Care Unit (
ICU) EHR data.We support the following datasets out of the box:DatasetMIMIC-III/IVeICU-CRDHiRIDAUMCdbAdmissions40k / 73k200k33k23kVersionv1.4 / v2.2v2.0v1.1.1v1.0.2Frequency(time-series)1 hour5 minutes2 / 5 minutesup to 1 minuteOriginally published2015  / 2020201720202019OriginUSAUSASwitzerlandNetherlandsNew datasets can also be added. We are currently working on a package to make this process as smooth as possible.
The benchmark is designed for operating on preprocessed parquet files.We provide five common tasks for clinical prediction by default:NoTaskFrequencyType1ICU MortalityOnce per Stay (after 24H)Binary Classification2Acute Kidney Injury (AKI)Hourly (within 6H)Binary Classification3SepsisHourly (within 6H)Binary Classification4Kidney Function(KF)Once per stayRegression5Length of Stay (LoS)Hourly (within 7D)RegressionNew tasks can be easily added.
For the purposes of getting started right away, we include the eICU and MIMIC-III demo datasets in our repository.The following repositories may be relevant as well:YAIB-cohorts: Cohort generation for YAIB.YAIB-models: Pretrained models for YAIB.ReciPys: Preprocessing package for YAIB pipelines.For all YAIB related repositories, please see:https://github.com/stars/rvandewater/lists/yaib.📄PaperTo reproduce the benchmarks in our paper, we refer to: theML reproducibility document.
If you use this code in your research, please cite the following publication:@article{vandewaterYetAnotherICUBenchmark2023,
	title = {Yet Another ICU Benchmark: A Flexible Multi-Center Framework for Clinical ML},
	shorttitle = {Yet Another ICU Benchmark},
	url = {http://arxiv.org/abs/2306.05109},
	language = {en},
	urldate = {2023-06-09},
	publisher = {arXiv},
	author = {Robin van de Water and Hendrik Schmidt and Paul Elbers and Patrick Thoral and Bert Arnrich and Patrick Rockenschaub},
	month = jun,
	year = {2023},
	note = {arXiv:2306.05109 [cs]},
	keywords = {Computer Science - Machine Learning},
}This paper can also be found on arxiv2306.05109💿InstallationYAIB is currently ideally installed from source, however we also offer it an early PyPi release.Installation from sourceFirst, we clone this repository using git:git clone https://github.com/rvandewater/YAIB.gitPlease note the branch. The newest features and fixes are available at the development branch:git checkout developmentYAIB can be installed using a conda environment (preferred) or pip. Below are the three CLI commands to install YAIB
usingconda.The first command will install an environment based on Python 3.10.conda env update -f <environment.yml|environment_mps.yml>Useenvironment.ymlon x86 hardware andenvironment_mps.ymlon Macs with Metal Performance Shaders.We then activate the environment and install a package calledicu-benchmarks, after which YAIB should be operational.conda activate yaib
pip install -e .If you want to install the icu-benchmarks package withpip, execute the command below:pip install torch numpy && pip install -e .After installation, please check if your Pytorch version works with CUDA (in case available) to ensure the best performance.
YAIB will automatically list available processors at initialization in its log files.👩‍💻UsagePlease refer toour wikifor detailed information on how to use YAIB.Quickstart 🚀 (demo data)In the folderdemo_datawe provide processed publicly available demo datasets from eICU and MIMIC with the necessary labels
forMortality at 24h,Sepsis,Akute Kidney Injury,Kidney Function, andLength of Stay.If you do not yet have access to the ICU datasets, you can run the following command to train models for the included demo
cohorts:wandb sweep --verbose experiments/demo_benchmark_classification.yml
wandb sweep --verbose experiments/demo_benchmark_regression.ymlwandb agent <sweep_id>Tip: You can choose to run each of the configurations on a SLURM cluster instance bywandb agent --count 1 <sweep_id>Note: You will need to have a wandb account and be logged in to run the above commands.Getting the datasetsHiRID, eICU, and MIMIC IV can be accessed throughPhysioNet. A guide to this process can be
foundhere.
AUMCdb can be accessed through a separate accessprocedure. We do not have
involvement in the access procedure and can not answer to any requests for data access.Cohort creationSince the datasets were created independently of each other, they do not share the same data structure or data identifiers. In
order to make them interoperable, use the preprocessing utilities
provided by thericu package.
Ricu pre-defines a large number of clinical concepts and how to load them from a given dataset, providing a common interface to
the data, that is used in this
benchmark. Please refer to ourcohort definitioncode for generating the cohorts
using our python interface for ricu.
After this, you can run the benchmark once you have gained access to the datasets.👟 Running YAIBPreprocessing and TrainingThe following command will run training and evaluation on the MIMIC demo dataset for (Binary) mortality prediction at 24h with
the
LGBMClassifier. Child samples are reduced due to the small amount of training data. We load available cache and, if available,
load
existing cache files.icu-benchmarks train \
    -d demo_data/mortality24/mimic_demo \
    -n mimic_demo \
    -t BinaryClassification \
    -tn Mortality24 \
    -m LGBMClassifier \
    -hp LGBMClassifier.min_child_samples=10 \
    --generate_cache
    --load_cache \
    --seed 2222 \
    -s 2222 \
    -l ../yaib_logs/ \
    --tuneFor a list of available flags, runicu-benchmarks train -h.Run withPYTORCH_ENABLE_MPS_FALLBACK=1on Macs with Metal Performance Shaders.For Windows based systems, the next line character (\)  needs to be replaced by (^) (Command Prompt) or (`) (Powershell)
respectively.Alternatively, the easiest method to train all the models in the paper is to run these commands from the directory root:wandb sweep --verbose experiments/benchmark_classification.yml
wandb sweep --verbose experiments/benchmark_regression.ymlThis will create two hyperparameter sweeps for WandB for the classification and regression tasks.
This configuration will train all the models in the paper. You can then run the following command to train the models:wandb agent <sweep_id>Tip: You can choose to run each of the configurations on a SLURM cluster instance bywandb agent --count 1 <sweep_id>Note: You will need to have a wandb account and be logged in to run the above commands.EvaluateIt is possible to evaluate a model trained on another dataset. In this case, the source dataset is the demo data from MIMIC and
the target is the eICU demo:icu-benchmarks evaluate \
    -d demo_data/mortality24/eicu_demo \
    -n eicu_demo \
    -t BinaryClassification \
    -tn Mortality24 \
    -m LGBMClassifier \
    --generate_cache \
    --load_cache \
    -s 2222 \
    -l ../yaib_logs \
    -sn mimic \
    --source-dir ../yaib_logs/mimic_demo/Mortality24/LGBMClassifier/2022-12-12T15-24-46/fold_0ModelsWe provide several existing machine learning models that are commonly used for multivariate time-series data.pytorchis used for the deep learning models,lightgbmfor the boosted tree approaches, andsklearnfor other classical
machine learning models.
The benchmark provides (among others) the following built-in models:Logistic Regression:
Standard regression approach.Elastic Net: Linear regression with
combined L1 and L2 priors as regularizer.LightGBM: Efficient gradient
boosting trees.Long Short-term Memory (LSTM): The most commonly used type of Recurrent Neural
Networks for long sequences.Gated Recurrent Unit (GRU): A extension to LSTM which showed
improvements (paper).Temporal Convolutional Networks (TCN): 1D convolution approach to sequence data. By
using dilated convolution to extend the receptive field of the network it has shown great performance on long-term
dependencies.Transformers: The most common Attention
based approach.🛠️ DevelopmentTo adapt YAIB to your own use case, you can use
thedevelopment informationpage as a reference.
We appreciate contributions to the project. Please read thecontribution guidelinesbefore submitting a pull
request.AcknowledgementsWe do not own any of the datasets used in this benchmark. This project uses heavily adapted components of
theHiRID benchmark. We thank the authors for providing this codebase and
encourage further development to benefit the scientific community. The demo datasets have been released under
anOpen Data Commons Open Database License (ODbL).LicenseThis source code is released under the MIT license, includedhere. We do not own any of the datasets used or
included in this repository.