K-Dense-AI/scientific-agent-skills / skills/pyhealth
pyhealth
VerifiedBuilds and validates PyHealth clinical machine-learning pipelines for EHR, signals, imaging, and medical codes. Use for PyHealth dataset loading, MIMIC-III/IV, eICU or OMOP prediction tasks, patient-level evaluation, mortality/readmission/length-of-stay modeling, medication recommendation, sleep staging, Trainer checkpoints, and ICD/ATC/NDC/RxNorm mapping.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.0 KB |
| assets/starter_pipeline.py | script | 3.8 KB |
| references/datasets.md | markdown | 5.2 KB |
| references/examples.md | markdown | 6.9 KB |
| references/installation.md | markdown | 4.4 KB |
| references/medcode.md | markdown | 3.6 KB |
| references/models.md | markdown | 5.8 KB |
| references/tasks.md | markdown | 6.5 KB |
references/installation.md
View on GitHub# Installation and environment
Reviewed for the released **PyHealth 2.0.2** wheel on 2026-09-30. Its metadata
requires Python `>=3.12,<3.14` and `torch~=2.7.1`, which excludes Torch 2.8 and later.
The tested macOS CPU environment resolved Torch 2.7.1 and torchvision 0.22.1.
Do not independently upgrade to the newest Torch or copy CUDA 12.1 commands from
older PyHealth examples. The [release metadata](https://pypi.org/project/pyhealth/2.0.2/)
is authoritative for this pin; `/en/latest/` documentation may describe newer source.
## Project setup
```bash
uv init --python 3.12 my-pyhealth-project
cd my-pyhealth-project
uv add 'pyhealth==2.0.2'
uv run python -c 'import torch; import importlib.metadata as m; print(m.version("pyhealth"), torch.__version__)'
```
Keep the generated lockfile. To run independently of the surrounding project's
Python requirement or dependencies:
```bash
uv run --no-project --isolated --python 3.12 --with pyhealth==2.0.2 python train.py
```
PyHealth 1.x has different datasets, task functions, schemas and model arguments.
Treat an existing 1.x environment as a separate migration; these examples target
2.0.2 and do not claim legacy compatibility.
## CPU, CUDA and MPS
Start with `Trainer(..., device="cpu")`. GPU selection at runtime does not determine
which wheel the installer downloads. For Linux CUDA/ROCm, choose a supported
**Torch 2.7.1 / torchvision 0.22.1** pair from the
[official previous-version installer](https://pytorch.org/get-started/previous-versions/),
and configure the package index appropriately for that environment. CUDA installation
was not tested in this review.
On Apple Silicon, check `torch.backends.mps.is_available()` before explicitly passing
`device="mps"`; the trainer's automatic device choice is CUDA-or-CPU. MPS operation
coverage is model-dependent and was not tested here. Optional graph models may need
`pyhealth[graph]==2.0.2`; pretrained text/image models can require separate downloads.
## Data access and layout
The public PyHealth `Synthetic_MIMIC-III` bucket is an unauthenticated collection of
CSV files, not a clinical production dataset or JSON API:
`https://storage.googleapis.com/pyhealth/Synthetic_MIMIC-III/`.
The 2.0.2 loader tries configured `.csv.gz` files and then `.csv` alternatives.
Real MIMIC and eICU require the relevant PhysioNet access conditions (credentialing,
training and the data use agreement). Confirm access and release-specific conditions
on the [dataset landing page](https://physionet.org/content/mimiciv/); download through
an authorized channel and pass a local path. Do not embed access credentials in code.
For MIMIC-IV the root must contain `hosp/` **and** `icu/` because the default config
loads `hosp/patients.csv.gz`, `hosp/admissions.csv.gz`, `icu/icustays.csv.gz` plus
requested clinical tables. PyHealth's bundled MIMIC-IV config is labeled 2.2;
compatibility with all newer PhysioNet releases has not been established here.
```python
from pyhealth.datasets import MIMIC4EHRDataset
base = MIMIC4EHRDataset(
root="./data/mimic-iv", # contains hosp/ and icu/
tables=["diagnoses_icd", "procedures_icd", "prescriptions"],
cache_dir="./cache/mimic4", num_workers=1,
)
```
This constructor was checked against released source; restricted data parsing was
not executed. MIMIC-III uses lowercase selectors with uppercase source filenames.
OMOP uses its own bundled config: inspect it before assuming a particular CDM export
naming convention.
## Caching and small runs
`BaseDataset(cache_dir=None)` uses a persistent platform-specific user cache.
An explicit cache root gains a dataset UUID subdirectory; task/schema/processor
caches live below it. It is incorrect that omitting `cache_dir` always reparses.
The dataset cache key includes root, tables, dataset name and `dev`, but not the raw
file contents or full config contents. A task source edit need not invalidate the
task cache either. Choose a new cache root after changing those inputs and record
raw-data checksums/release and task version with each run.
`dev=True` limits BaseDataset processing to 1000 patients; it is not a guarantee
that only 1000 patients' CSV bytes are downloaded or scanned. Not every wrapper
exposes it: `SleepEDFDataset`, for example, has no `dev` or `cache_dir` parameter.
Use a `main()` guard for executable examples because dataset processing can spawn
workers on macOS/Windows. `num_workers=1` is a useful initial setting, not a guarantee
that every upstream library avoids subprocesses.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |