
Pyhealth
Stand up reproducible clinical deep-learning pipelines—dataset load, task definition, model choice, Trainer loop, and clinical metrics—for EHR, signal, and imaging studies with PyHealth.
Overview
PyHealth is an agent skill most often used in Build (also Validate, Ship) that implements the PyHealth clinical ML pipeline from datasets and tasks through models, training, and clinical metrics.
Install
npx skills add https://github.com/k-dense-ai/scientific-agent-skills --skill pyhealthWhat is this skill?
- Follows PyHealth’s replaceable 5-stage pipeline: Dataset → Task → Model → Trainer → Metrics
- Covers EHR and clinical datasets including MIMIC-III/IV, eICU, OMOP, SleepEDF, ChestXray14, and EHRShot
- Supports tasks such as mortality, readmission, length-of-stay, drug recommendation, sleep staging, ICD coding, and EEG e
- Includes model families (Transformer, RETAIN, GAMENet, SafeDrug, MICRON, StageNet, AdaCare, CNN/RNN/MLP) and ICD/ATC/NDC
- Documents a 5-stage pipeline: Dataset → Task → Model → Trainer → Metrics
Adoption & trust: 521 installs on skills.sh; 27.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have a healthcare prediction or coding idea but no structured way to load MIMIC-style data, define a clinical task, pick a model, and train with consistent metrics in one agent session.
Who is it for?
Indie builders prototyping or shipping clinical ML on MIMIC, eICU, OMOP, or imaging/signal benchmarks who want library-native Dataset → Task → Model → Trainer composition.
Skip if: Non-clinical web apps, teams without licensed or appropriate access to restricted health datasets, or workflows that only need generic sklearn tabular models with no EHR semantics.
When should I use this skill?
User mentions PyHealth, MIMIC, eICU, OMOP, EHR modeling, clinical prediction, drug recommendation, sleep staging, ICD/ATC codes, or any healthcare ML workflow matching dataset → task → model → trainer → metrics.
What do I get? / Deliverables
You get a PyHealth-aligned pipeline with chosen dataset, task, model, Trainer run, and clinical metrics ready to iterate or harden for deployment review.
- Configured PyHealth Dataset, Task, and Model instances
- Trainer run outputs and clinical evaluation metrics for the chosen task
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
PyHealth is where healthcare ML products get their training and evaluation backbone; the canonical shelf is Build because the skill centers on implementing the Dataset → Task → Model → Trainer → Metrics pipeline in code. Backend fits the modular Python training stack, medical code utilities, and OMOP/MIMIC-style data interfaces rather than UI or launch work.
Where it fits
Spin up a readmission or mortality task on MIMIC-III/IV with a baseline RETAIN or Transformer to see if the clinical signal is worth a full product build.
Implement the full PyHealth Trainer loop for length-of-stay or drug recommendation with GAMENet or SafeDrug and medical code crosswalks.
Re-run training and clinical metrics on a held-out split before tagging a model artifact for staging or demo deployment.
How it compares
Use this skill for the PyHealth 5-stage clinical DL pattern instead of one-off PyTorch scripts that skip task and medical-code abstractions.
Common Questions / FAQ
Who is pyhealth for?
It is for solo and small-team developers using coding agents to build EHR, physiological signal, or medical imaging models with PyHealth and standard clinical benchmarks.
When should I use pyhealth?
Use it in Validate to prototype mortality or readmission tasks on public cohorts, in Build to wire Dataset → Task → Model → Trainer end-to-end, and in Ship when you re-run training and clinical metrics before release.
Is pyhealth safe to install?
The skill guides modeling patterns only; handle PHI and dataset licenses yourself and review the Security Audits panel on this Prism page before installing from the repo.
SKILL.md
READMESKILL.md - Pyhealth
# PyHealth PyHealth (https://pyhealth.dev/) is a Python toolkit for clinical deep learning. It provides a unified, modular pipeline across electronic health records (EHR), physiological signals, and medical imaging. The library is built around a **5-stage pipeline** — `Dataset → Task → Model → Trainer → Metrics` — where each stage is replaceable and the interfaces between stages are stable. Code that follows this pipeline shape composes well; code that bypasses it usually fights the library. ## When to use this skill Use this skill whenever the user is doing clinical/healthcare ML and any of the following are true: - They mention PyHealth, MIMIC-III/IV, eICU, OMOP-CDM, EHRShot, SleepEDF, SHHS, ISRUC, COVID19-CXR, ChestX-ray14, TUEV/TUAB. - They want to predict mortality, readmission, length of stay, drug recommendations, sleep stages, ICD codes, EEG events, or de-identification. - They need to look up or cross-map medical codes (ICD-9-CM, ICD-10-CM, ATC, NDC, RxNorm, CCS). - They have EHR-shaped data and want to train a clinical model without writing the plumbing themselves. PyHealth is the right tool when the workflow fits its 5 stages. If the user just wants generic PyTorch on tabular data, this skill is not necessary. ## Installation (uv) PyHealth 2.0 requires Python ≥ 3.12, < 3.14. Use `uv` for environment management — it's faster and reproducible. ```bash # Create a project with the right Python uv init my-pyhealth-project cd my-pyhealth-project uv python pin 3.12 # Add PyHealth (this also pulls in PyTorch and friends) uv add pyhealth # Run scripts inside the env uv run python train.py ``` For a one-off script without a project, use `uv run --with pyhealth python script.py`. For the legacy 1.x line (Python 3.9+), `uv add pyhealth==1.16`. Detailed install notes, MIMIC access, and GPU/CPU device tips are in `references/installation.md`. ## The 5-stage pipeline A complete pipeline is typically <20 lines. This is the canonical shape — start here and modify pieces: ```python from pyhealth.datasets import MIMIC3Dataset, split_by_patient, get_dataloader from pyhealth.tasks import MortalityPredictionMIMIC3 from pyhealth.models import Transformer from pyhealth.trainer import Trainer from pyhealth.metrics.binary import binary_metrics_fn # 1. Dataset — raw patient registry base = MIMIC3Dataset( root="https://storage.googleapis.com/pyhealth/Synthetic_MIMIC-III/", tables=["DIAGNOSES_ICD", "PROCEDURES_ICD", "PRESCRIPTIONS"], ) # 2. Task — converts patients into supervised samples samples = base.set_task(MortalityPredictionMIMIC3()) # 3. Split + DataLoaders (split by patient to avoid leakage) 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) val_loader = get_dataloader(val_ds, batch_size=32, shuffle=False) test_loader = get_dataloader(test_ds, batch_size=32, shuffle=False) # 4. Model — must be passed the SampleDataset, not the BaseDataset model = Transformer(dataset=samples) # 5. Train + evaluate trainer = Trai