What problem does it solve?
PyHealth solves the problem of developing, testing, and deploying machine learning models with clinical data, simplifying healthcare AI research and application.
Core Features & Use Cases
- Comprehensive Datasets: Access to MIMIC-III/IV, eICU, OMOP, and more healthcare datasets for research.
- Predictive Models: Implement deep learning models for healthcare applications, such as mortality prediction, drug recommendation, and readmission risk.
- Custom Task Definition: Create custom tasks for prediction objectives with defined input/output schemas.
- Model Selection: Choose from baselines, deep learning models, and healthcare-specific models for clinical tasks.
- Training and Evaluation: Efficient training and evaluation with built-in tools and metrics.
Quick Start
Run the following command to start predicting patient mortality using PyHealth:
from pyhealth.datasets import MIMIC4Dataset
from pyhealth.tasks import mortality_prediction_mimic4_fn
from pyhealth.models import Transformer
from pyhealth.trainer import Trainer
dataset = MIMIC4Dataset(root="/path/to/data")
sample_dataset = dataset.set_task(mortality_prediction_mimic4_fn)
train, val, test = split_by_patient(sample_dataset, [0.7, 0.1, 0.2])
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)
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"
)
results = trainer.evaluate(test_loader)
print(results)