New PyHealth 2.1.0: leakage-free splits, calibration with confidence intervals, XGBoost + TreeSHAP, and nine Colab tutorials

Open-Source Healthcare AI

A Python toolkit for clinical deep learning — unifying datasets, tasks, and models across electronic health records, physiological signals, and medical imaging.

pip install pyhealth
25+
Clinical
Datasets
50+
Clinical
Tasks
50+
ML
Models
750+
Discord
Members
10+
Active
Researchers

Used in published research by teams at

Stanford UniversityHarvard UniversityCornell University Weill Cornell MedicineUniversity of PennsylvaniaDuke University Emory UniversityThe Ohio State UniversityGeorgia Tech UNC Chapel HillWashington University in St. Louis Cincinnati Children's HospitalOak Ridge National Laboratory AstraZenecaKing's College LondonHeidelberg University InsermTsinghua UniversityPeking University Chinese Academy of SciencesUniversity of Hong Kong Nanyang Technological UniversityKorea University Ben-Gurion University of the Negev

and 42 more institutions · 81 papers using or citing PyHealth

What PyHealth saves you

Most of a clinical ML project is the work around the model. PyHealth ships that work, tested and shared, so your time goes to the idea.

Without PyHealth
With PyHealth
Load the data
Write and debug a custom ETL for MIMIC, eICU or OMOP, for every project
25+ dataset loaders: one line per dataset, cached after the first run
Define the cohort and label
Re-derive cohort, label and time window from a paper's methods section
50+ ready-made, tested clinical tasks, or your own as one small class
Compare against baselines
Re-implement each baseline and hope it matches the original
50+ models behind one API: swapping models is a one-line change
Evaluate so reviewers trust it
Patients leak across splits; one test number with no interval
Leakage-free patient splits, calibration and patient-level bootstrap confidence intervals
Scale to real data
Pandas pipelines that need a server for full MIMIC-IV
Full MIMIC-IV mortality on a laptop in about 5 GB, up to 39× faster than pandas
Get your work used
Research code that stops working when the student graduates
Your method in a library used in 81 papers at 60+ institutions

5-Stage Pipeline in <15 Lines

The same pattern works for any task — swap the dataset and task class to move between mortality, readmission, drug recommendation, or imaging.

Mortality prediction on MIMIC-III

from pyhealth.datasets import MIMIC3Dataset, PatientSplit, get_dataloader
from pyhealth.models import Transformer
from pyhealth.tasks import MortalityPredictionMIMIC3
from pyhealth.trainer import Trainer

if __name__ == "__main__":
    # 1. Load data: raw tables are processed once and cached
    dataset = MIMIC3Dataset(
        root="data/mimic3",
        tables=["diagnoses_icd", "procedures_icd", "prescriptions"],
        cache_dir="cache/",
    )

    # 2. Task + patient split: preprocessing is fit on training patients only
    train_ds, val_ds, test_ds = dataset.set_task(
        MortalityPredictionMIMIC3(), split=PatientSplit((0.8, 0.1, 0.1), seed=0)
    )
    train_loader = get_dataloader(train_ds, batch_size=32, shuffle=True)
    val_loader = get_dataloader(val_ds, batch_size=32)
    test_loader = get_dataloader(test_ds, batch_size=32)

    # 3. Train and evaluate
    model = Transformer(dataset=train_ds)
    trainer = Trainer(model=model, metrics=["pr_auc", "roc_auc"])
    trainer.train(train_loader, val_loader, epochs=50, monitor="pr_auc")
    print(trainer.evaluate(test_loader))

Built for Scale — Efficient by Design

Benchmarked on MIMIC-IV at 4 parallel workers. PyHealth 2.0 uses a memory-mapped architecture that dynamically adapts to your hardware — whether you have 2 cores or 64, it scales without manual memory management so you can focus on the ML, not the infrastructure. Pandas values shown at 1 worker only (†) as it could not scale beyond single-threaded execution. PyHealth 2.0 even runs the full in-hospital mortality task on a consumer laptop in roughly 5 GB of memory.

39×
Faster than pandas
20×
Less memory than pandarallel

Drug Recommendation

Wall Time (hours · lower is better)

PyHealth 2.0
0.23h
PyHealth 1.16
0.27h
Pandas †
1.31h
MEDS
2.91h

Peak Memory (GB · lower is better)

PyHealth 2.0
8.9 GB
Pandas †
10.4 GB
MEDS
61.7 GB
PyHealth 1.16
83.2 GB

Length of Stay Prediction

Wall Time (hours · lower is better)

PyHealth 1.16
0.64h
PyHealth 2.0
0.69h
Pandas †
2.85h
MEDS
3.32h

Peak Memory (GB · lower is better)

PyHealth 2.0
8.5 GB
Pandas †
11.4 GB
MEDS
61.8 GB
PyHealth 1.16
80.9 GB

In-Hospital Mortality

Wall Time (hours · lower is better)

MacBook M2 Pro
0.56h
ASUS G16
0.73h
PyHealth 1.16
0.88h
Server WS
1.28h
MEDS
2.96h
Pandas †
26.03h

Peak Memory (GB · lower is better)

MacBook M2 Pro
5.3 GB
ASUS G16
19.2 GB
Server WS
23.4 GB
Pandas †
49.2 GB
MEDS
60.0 GB
PyHealth 1.16
187.2 GB
PyHealth 2.0 (workstation) PyHealth 2.0 (laptop) PyHealth 1.16 MEDS Pandas † (1 worker only)

† Pandas measured at 1 worker; failed beyond single-threaded execution. All other methods at 4 workers on MIMIC-IV. Laptop rows are PyHealth 2.0 on a MacBook Pro M2 Pro and an ASUS Zephyrus G16 at 4 workers, benchmarked for in-hospital mortality. Full benchmark in the PyHealth 2.0 paper (ICML 2026).

How PyHealth Standardizes Clinical AI Development

A unified API from raw clinical data to trustworthy, interpretable models — follow the pipeline step by step.

Resources

Everything you need to get started or get involved.

Cite PyHealth

If PyHealth helps your research, please cite the PyHealth 2.0 paper (ICML 2026). If you use the 1.x releases, cite the KDD 2023 paper.

PyHealth 2.0 · ICML 2026

@inproceedings{wu2026pyhealth,
  title={PyHealth 2.0: A Comprehensive Open-Source Toolkit for Accessible and Reproducible Clinical Deep Learning},
  author={John Wu and Yongda Fan and Zhenbang Wu and Paul Landes and Eric Schrock and Sayeed Sajjad Razin and Arjun Chatterjee and Naveen Baskaran and Joshua Steier and Andrea Fitzpatrick and Bilal Arif and Rian Atri and Jathurshan Pradeepkumar and Siddhartha Laghuvarapu and Junyi Gao and Adam Richard Cross and Jimeng Sun},
  booktitle={Forty-third International Conference on Machine Learning},
  year={2026},
  url={https://openreview.net/forum?id=gMLVFN9hl8}
}

PyHealth 1.0 · KDD 2023

ACM DL →
@inproceedings{pyhealth2023yang,
  author={Yang, Chaoqi and Wu, Zhenbang and Jiang, Patrick and Lin, Zhen and Gao, Junyi and Danek, Benjamin P. and Sun, Jimeng},
  title={{PyHealth}: A Deep Learning Toolkit for Healthcare Applications},
  booktitle={Proceedings of the 29th ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  pages={5788--5789},
  year={2023},
  doi={10.1145/3580305.3599178}
}