pyhealth

48
2
Source

Comprehensive healthcare AI toolkit for developing, testing, and deploying machine learning models with clinical data. This skill should be used when working with electronic health records (EHR), clinical prediction tasks (mortality, readmission, drug recommendation), medical coding systems (ICD, NDC, ATC), physiological signals (EEG, ECG), healthcare datasets (MIMIC-III/IV, eICU, OMOP), or implementing deep learning models for healthcare applications (RETAIN, SafeDrug, Transformer, GNN).

Install

mkdir -p .claude/skills/pyhealth && curl -L -o skill.zip "https://mcp.directory/api/skills/download/908" && unzip -o skill.zip -d .claude/skills/pyhealth && rm skill.zip

Installs to .claude/skills/pyhealth

About this skill

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.

When to Use This Skill

Invoke this skill when:

  • Working with healthcare datasets: MIMIC-III, MIMIC-IV, eICU, OMOP, sleep EEG data, medical images
  • Clinical prediction tasks: Mortality prediction, hospital readmission, length of stay, drug recommendation
  • Medical coding: Translating between ICD-9/10, NDC, RxNorm, ATC coding systems
  • Processing clinical data: Sequential events, physiological signals, clinical text, medical images
  • Implementing healthcare models: RETAIN, SafeDrug, GAMENet, StageNet, Transformer for EHR
  • Evaluating clinical models: Fairness metrics, calibration, interpretability, uncertainty quantification

Core Capabilities

PyHealth operates through a modular 5-stage pipeline optimized for healthcare AI:

  1. Data Loading: Access 10+ healthcare datasets with standardized interfaces
  2. Task Definition: Apply 20+ predefined clinical prediction tasks or create custom tasks
  3. Model Selection: Choose from 33+ models (baselines, deep learning, healthcare-specific)
  4. Training: Train with automatic checkpointing, monitoring, and evaluation
  5. Deployment: Calibrate, interpret, and validate for clinical use

Performance: 3x faster than pandas for healthcare data processing

Quick Start Workflow

from pyhealth.datasets import MIMIC4Dataset
from pyhealth.tasks import mortality_prediction_mimic4_fn
from pyhealth.datasets import split_by_patient, get_dataloader
from pyhealth.models import Transformer
from pyhealth.trainer import Trainer

# 1. Load dataset and set task
dataset = MIMIC4Dataset(root="/path/to/data")
sample_dataset = dataset.set_task(mortality_prediction_mimic4_fn)

# 2. Split data
train, val, test = split_by_patient(sample_dataset, [0.7, 0.1, 0.2])

# 3. Create data loaders
train_loader = get_dataloader(train, batch_size=64, shuffle=True)
val_loader = get_dataloader(val, batch_size=64, shuffle=False)
test_loader = get_dataloader(test, batch_size=64, shuffle=False)

# 4. Initialize and train model
model = Transformer(
    dataset=sample_dataset,
    feature_keys=["diagnoses", "medications"],
    mode="binary",
    embedding_dim=128
)

trainer = Trainer(model=model, device="cuda")
trainer.train(
    train_dataloader=train_loader,
    val_dataloader=val_loader,
    epochs=50,
    monitor="pr_auc_score"
)

# 5. Evaluate
results = trainer.evaluate(test_loader)

Detailed Documentation

This skill includes comprehensive reference documentation organized by functionality. Read specific reference files as needed:

1. Datasets and Data Structures

File: references/datasets.md

Read when:

  • Loading healthcare datasets (MIMIC, eICU, OMOP, sleep EEG, etc.)
  • Understanding Event, Patient, Visit data structures
  • Processing different data types (EHR, signals, images, text)
  • Splitting data for training/validation/testing
  • Working with SampleDataset for task-specific formatting

Key Topics:

  • Core data structures (Event, Patient, Visit)
  • 10+ available datasets (EHR, physiological signals, imaging, text)
  • Data loading and iteration
  • Train/val/test splitting strategies
  • Performance optimization for large datasets

2. Medical Coding Translation

File: references/medical_coding.md

Read when:

  • Translating between medical coding systems
  • Working with diagnosis codes (ICD-9-CM, ICD-10-CM, CCS)
  • Processing medication codes (NDC, RxNorm, ATC)
  • Standardizing procedure codes (ICD-9-PROC, ICD-10-PROC)
  • Grouping codes into clinical categories
  • Handling hierarchical drug classifications

Key Topics:

  • InnerMap for within-system lookups
  • CrossMap for cross-system translation
  • Supported coding systems (ICD, NDC, ATC, CCS, RxNorm)
  • Code standardization and hierarchy traversal
  • Medication classification by therapeutic class
  • Integration with datasets

3. Clinical Prediction Tasks

File: references/tasks.md

Read when:

  • Defining clinical prediction objectives
  • Using predefined tasks (mortality, readmission, drug recommendation)
  • Working with EHR, signal, imaging, or text-based tasks
  • Creating custom prediction tasks
  • Setting up input/output schemas for models
  • Applying task-specific filtering logic

Key Topics:

  • 20+ predefined clinical tasks
  • EHR tasks (mortality, readmission, length of stay, drug recommendation)
  • Signal tasks (sleep staging, EEG analysis, seizure detection)
  • Imaging tasks (COVID-19 chest X-ray classification)
  • Text tasks (medical coding, specialty classification)
  • Custom task creation patterns

4. Models and Architectures

File: references/models.md

Read when:

  • Selecting models for clinical prediction
  • Understanding model architectures and capabilities
  • Choosing between general-purpose and healthcare-specific models
  • Implementing interpretable models (RETAIN, AdaCare)
  • Working with medication recommendation (SafeDrug, GAMENet)
  • Using graph neural networks for healthcare
  • Configuring model hyperparameters

Key Topics:

  • 33+ available models
  • General-purpose: Logistic Regression, MLP, CNN, RNN, Transformer, GNN
  • Healthcare-specific: RETAIN, SafeDrug, GAMENet, StageNet, AdaCare
  • Model selection by task type and data type
  • Interpretability considerations
  • Computational requirements
  • Hyperparameter tuning guidelines

5. Data Preprocessing

File: references/preprocessing.md

Read when:

  • Preprocessing clinical data for models
  • Handling sequential events and time-series data
  • Processing physiological signals (EEG, ECG)
  • Normalizing lab values and vital signs
  • Preparing labels for different task types
  • Building feature vocabularies
  • Managing missing data and outliers

Key Topics:

  • 15+ processor types
  • Sequence processing (padding, truncation)
  • Signal processing (filtering, segmentation)
  • Feature extraction and encoding
  • Label processors (binary, multi-class, multi-label, regression)
  • Text and image preprocessing
  • Common preprocessing workflows

6. Training and Evaluation

File: references/training_evaluation.md

Read when:

  • Training models with the Trainer class
  • Evaluating model performance
  • Computing clinical metrics
  • Assessing model fairness across demographics
  • Calibrating predictions for reliability
  • Quantifying prediction uncertainty
  • Interpreting model predictions
  • Preparing models for clinical deployment

Key Topics:

  • Trainer class (train, evaluate, inference)
  • Metrics for binary, multi-class, multi-label, regression tasks
  • Fairness metrics for bias assessment
  • Calibration methods (Platt scaling, temperature scaling)
  • Uncertainty quantification (conformal prediction, MC dropout)
  • Interpretability tools (attention visualization, SHAP, ChEFER)
  • Complete training pipeline example

Installation

uv pip install pyhealth

Requirements:

  • Python ≥ 3.7
  • PyTorch ≥ 1.8
  • NumPy, pandas, scikit-learn

Common Use Cases

Use Case 1: ICU Mortality Prediction

Objective: Predict patient mortality in intensive care unit

Approach:

  1. Load MIMIC-IV dataset → Read references/datasets.md
  2. Apply mortality prediction task → Read references/tasks.md
  3. Select interpretable model (RETAIN) → Read references/models.md
  4. Train and evaluate → Read references/training_evaluation.md
  5. Interpret predictions for clinical use → Read references/training_evaluation.md

Use Case 2: Safe Medication Recommendation

Objective: Recommend medications while avoiding drug-drug interactions

Approach:

  1. Load EHR dataset (MIMIC-IV or OMOP) → Read references/datasets.md
  2. Apply drug recommendation task → Read references/tasks.md
  3. Use SafeDrug model with DDI constraints → Read references/models.md
  4. Preprocess medication codes → Read references/medical_coding.md
  5. Evaluate with multi-label metrics → Read references/training_evaluation.md

Use Case 3: Hospital Readmission Prediction

Objective: Identify patients at risk of 30-day readmission

Approach:

  1. Load multi-site EHR data (eICU or OMOP) → Read references/datasets.md
  2. Apply readmission prediction task → Read references/tasks.md
  3. Handle class imbalance in preprocessing → Read references/preprocessing.md
  4. Train Transformer model → Read references/models.md
  5. Calibrate predictions and assess fairness → Read references/training_evaluation.md

Use Case 4: Sleep Disorder Diagnosis

Objective: Classify sleep stages from EEG signals

Approach:

  1. Load sleep EEG dataset (SleepEDF, SHHS) → Read references/datasets.md
  2. Apply sleep staging task → Read references/tasks.md
  3. Preprocess EEG signals (filtering, segmentation) → Read references/preprocessing.md
  4. Train CNN or RNN model → Read references/models.md
  5. Evaluate per-stage performance → Read references/training_evaluation.md

Use Case 5: Medical Code Translation

Objective: Standardize diagnoses across different coding systems

Approach:

  1. Read references/medical_coding.md for comprehensive guidance
  2. Use CrossMap to translate between ICD-9, ICD-10, CCS
  3. Group codes into clinically meaningful categories
  4. Integrate with dataset processing

Use Case 6: Clinical Text to ICD Coding

Objective: Automatically assign ICD codes from clinical notes

Approach:

  1. Load MIMIC-III with clinical text → Read references/datasets.md
  2. Apply ICD coding task → Read references/tasks.md
  3. Preprocess clinical text → Read references/preprocessing.md
  4. Use TransformersModel (ClinicalBERT) → Read references/models.md
  5. Evaluate with multi-label metrics → Read `references/training_evaluation

Content truncated.

software-architecture

davila7

Guide for quality focused software architecture. This skill should be used when users want to write code, design architecture, analyze code, in any case that relates to software development.

469162

scroll-experience

davila7

Expert in building immersive scroll-driven experiences - parallax storytelling, scroll animations, interactive narratives, and cinematic web experiences. Like NY Times interactives, Apple product pages, and award-winning web experiences. Makes websites feel like experiences, not just pages. Use when: scroll animation, parallax, scroll storytelling, interactive story, cinematic website.

12580

planning-with-files

davila7

Implements Manus-style file-based planning for complex tasks. Creates task_plan.md, findings.md, and progress.md. Use when starting complex multi-step tasks, research projects, or any task requiring >5 tool calls.

7966

humanizer

davila7

Remove signs of AI-generated writing from text. Use when editing or reviewing text to make it sound more natural and human-written. Based on Wikipedia's comprehensive "Signs of AI writing" guide. Detects and fixes patterns including: inflated symbolism, promotional language, superficial -ing analyses, vague attributions, em dash overuse, rule of three, AI vocabulary words, negative parallelisms, and excessive conjunctive phrases. Credits: Original skill by @blader - https://github.com/blader/humanizer

10250

game-development

davila7

Game development orchestrator. Routes to platform-specific skills based on project needs.

14549

2d-games

davila7

2D game development principles. Sprites, tilemaps, physics, camera.

12744

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,5641,368

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

1,1061,184

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

1,4141,106

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

1,192746

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

1,147683

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

1,304608

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.