ehr-analysis
БесплатноБез исполняемых скриптовНе проверенEnd-to-end EHR predictive modeling pipeline with PyHealth, covering dataset loading, task definition, model training, evaluation, calibration, and clinical…
от gabrielmoreira★ 23 звезды на GitHubОб этом скилле
EHR Analysis
Version Compatibility
Reference examples assume:
pyhealth1.1.6+ (stable) or 2.0+ (latest, requires Python ≥ 3.12)torch2.0+pandas2.0+
Verify the runtime first:
- Python:
python -c "import pyhealth; print(pyhealth.__version__)" - CLI:
pip show pyhealth - If APIs differ between 1.x and 2.x, consult the installed docs and adapt the pattern accordingly.
Overview
Use this skill when the user needs to:
- load and structure EHR data from MIMIC-III, MIMIC-IV, eICU, OMOP-CDM, or a custom dataset
- define clinical prediction tasks such as mortality, readmission, length of stay, or drug recommendation
- train and evaluate deep learning or ML models on patient visit sequences
- apply medical code normalization, ontology mapping, or tokenization
- calibrate model outputs or generate post-hoc interpretability artifacts
When To Use This Skill
- the data source is a structured EHR database or tabular patient record export
- the task requires longitudinal patient visit sequences as model input
- the user needs benchmark-compatible evaluation metrics for clinical AI
- medical code systems (ICD, ATC, NDC, CPT, CCS) must be normalized or mapped before modeling
Quick Route
- Known EHR source (MIMIC, eICU, OMOP): load with a
pyhealth.datasetsclass, thenset_task. - Custom tabular data: wrap in
SampleBaseDataset, then follow the same pipeline. - Code mapping only: use
pyhealth.medcodeindependently without the full pipeline. - Evaluation only: use
pyhealth.metricsindependently on existing predictions.
Progressive Disclosure
- Read
references/technical_reference.mdfor dataset branching rules, task schema details, model selection guidance, and calibration caveats. - Read
references/commands_and_thresholds.mdfor concrete PyHealth code patterns, recommended thresholds, and output file conventions. - Keep
SKILL.mdas the main execution path and load reference files only when the task or failure mode needs the extra detail.
Default Rules
- Always use raw integer counts or visit-level code lists as model inputs; do not pre-aggregate before loading.
- Keep dataset loading, task definition, model training, and evaluation as separate, inspectable stages.
- Record dataset name, table selections, code mapping applied, task function, model class, and PyHealth version in every experiment.
- Favor reproducible train/val/test splits via
split_by_patientover random splits that can leak patient data.
Expected Inputs
- EHR source files or database dumps (MIMIC-III, MIMIC-IV, eICU, OMOP-CDM, or custom CSV/Parquet)
- table names to load (e.g.,
diagnoses_icd,procedures_icd,prescriptions) - optional medical code mapping specifications
- task definition (predefined or custom)
- model architecture choice and training hyperparameters
Expected Outputs
results/model_checkpoint.pthresults/test_metrics.jsonresults/predictions.tsvqc/dataset_stats.tsvfigures/calibration_curve.pdffigures/feature_importance.pdf
Preferred Tools
pyhealth.datasets— MIMIC3Dataset, MIMIC4Dataset, eICUDataset, OMOPDataset, SampleBaseDatasetpyhealth.tasks— MortalityPrediction, ReadmissionPrediction, DrugRecommendation, LengthOfStayPrediction, and custom task functionspyhealth.models— RNN, LSTM, GRU, Transformer, RETAIN, SafeDrug, GAMENet, AdaCare, ConCare, StageNetpyhealth.trainer— Trainerpyhealth.metrics— binary, multiclass, multilabel, fairness, interpretability metricspyhealth.medcode— InnerMap, CrossMap for ontology lookup and code mappingpyhealth.tokenizer— Tokenizer for code-to-index transformationspyhealth.calib— calibration and prediction set construction
Starter Pattern
from pyhealth.datasets import MIMIC3Dataset
from pyhealth.tasks import drug_recommendation_mimic3_fn
from pyhealth.datasets import split_by_patient, get_dataloader
from pyhealth.models import Transformer
from pyhealth.trainer import Trainer
# Step 1: load dataset
dataset = MIMIC3Dataset(
root="/path/to/mimic3/",
tables=["DIAGNOSES_ICD", "PROCEDURES_ICD", "PRESCRIPTIONS"],
code_mapping={"NDC": ("ATC", {"target_kwargs": {"level": 3}})},
)
# Step 2: define task
samples = dataset.set_task(task_fn=drug_recommendation_mimic3_fn)
# Step 3: split and build dataloaders
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)
# Step 4: initialize model
model = Transformer(
dataset=samples,
feature_keys=["conditions", "procedures"],
label_key="drugs",
mode="multilabel",
)
# Step 5: train
trainer = Trainer(model=model)
trainer.train(
train_dataloader=train_loader,
val_dataloader=val_loader,
epochs=50,
monitor="pr_auc_samples",
)
# Step 6: evaluate
metri
Установить ehr-analysis в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл ehr-analysis?
End-to-end EHR predictive modeling pipeline with PyHealth, covering dataset loading, task definition, model training, evaluation, calibration, and clinical interpretation.
Как установить скилл ehr-analysis?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ehr-analysis запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic