alterlab-pyhealth
Installation
SKILL.md
PyHealth: Healthcare AI Toolkit
Overview
PyHealth is a comprehensive Python library for healthcare AI that provides specialized tools, models, and datasets for clinical machine learning. Use this skill when developing healthcare prediction models, processing clinical data, working with medical coding systems, or deploying AI solutions in healthcare settings.
Version gotcha (read first). This skill targets PyHealth 2.x (pin
pyhealth==2.0.1). The 2.0 rewrite changed the API in ways the wider web (and pre-2024 tutorials) get wrong:
- Tasks are classes you instantiate, e.g.
MortalityPredictionMIMIC4(),DrugRecommendationMIMIC3()— not the old snake-casemortality_prediction_mimic4_fnfunctions. Pass the instance todataset.set_task(task).- Datasets take an explicit
tables=[...]list (e.g.tables=["diagnoses_icd", "procedures_icd", "prescriptions"]).- Models require
label_key=in addition tofeature_keys=andmode=. Common feature keys for EHR tasks are"conditions","procedures","drugs".- Metric names have no
_scoresuffix:pr_auc,roc_auc,f1; multilabel/drug-rec use the*_samplesfamily (jaccard_samples,f1_samples,pr_auc_samples,ddi). Passmetrics=[...]to theTrainerconstructor, andmonitor=one of those names.- 2.0.1 requires Python 3.12 or 3.13 (
>=3.12,<3.14). When unsure of a class/arg name, check the current source rather than trusting older snippets.
When to Use This Skill
Invoke this skill when: