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
20+
Clinical
Datasets
26+
Clinical
Tasks
50+
ML
Models
400+
Discord
Members
10+
Active
Researchers

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
from pyhealth.tasks import MortalityPredictionMIMIC3
from pyhealth.datasets import split_by_patient, get_dataloader
from pyhealth.models import Transformer
from pyhealth.trainer import Trainer

if __name__ == "__main__":
    # 1. Load data
    dataset = MIMIC3Dataset(root="data/", tables=["DIAGNOSES_ICD", "PROCEDURES_ICD"])
    samples = dataset.set_task(MortalityPredictionMIMIC3())

    # 2. Split & load
    train_ds, val_ds, test_ds = split_by_patient(samples, [0.8, 0.1, 0.1])
    train_loader = get_dataloader(train_ds, batch_size=32, shuffle=True)

    # 3. Train
    model = Transformer(dataset=samples)
    trainer = Trainer(model=model)
    trainer.train(train_loader, val_loader, epochs=50, monitor="pr_auc")
    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.

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.