Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/benchmark_perf/loc/minimal_legacy_drug_rec.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Requires pyhealth==1.1.6 (legacy 1.x task_fn/Visit API) -- not runnable against pyhealth 2.0
from pyhealth.data import Patient,Visit; from pyhealth.datasets import MIMIC4Dataset

def drug_recommendation_mimic4_fn(patient):
Expand Down
1 change: 1 addition & 0 deletions examples/benchmark_perf/loc/minimal_legacy_los.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Requires pyhealth==1.1.6 (legacy 1.x task_fn/Visit API) -- not runnable against pyhealth 2.0
from pyhealth.datasets import MIMIC4Dataset

def categorize_los(d): return 0 if d<1 else (d if d<=7 else (8 if d<=14 else 9))
Expand Down
1 change: 1 addition & 0 deletions examples/benchmark_perf/loc/minimal_legacy_mortality.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Requires pyhealth==1.1.6 (legacy 1.x task_fn/Visit API) -- not runnable against pyhealth 2.0
from collections import defaultdict; from pyhealth.data import Patient; from pyhealth.datasets import MIMIC4Dataset
from typing import Dict,List

Expand Down
27 changes: 8 additions & 19 deletions examples/drug_recommendation/drug_recommendation_mimic4_gamenet.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# import pyhealth
import pyhealth

# import mimic4 dataset and drug recommendaton task
# import mimic4 dataset and drug recommendation task
from pyhealth.datasets import MIMIC4Dataset
from pyhealth.tasks import drug_recommendation_mimic4_fn
from pyhealth.tasks import DrugRecommendationMIMIC4

# import dataloader related functions
from pyhealth.datasets.splitter import split_by_patient
from pyhealth.datasets import split_by_patient, get_dataloader

# import gamenet model
Expand All @@ -23,16 +19,14 @@

def prepare_drug_task_data():
mimicvi = MIMIC4Dataset(
root="/srv/local/data/physionet.org/files/mimiciv/2.0/hosp",
tables=["diagnoses_icd", "procedures_icd", "prescriptions"],
ehr_root="/srv/local/data/physionet.org/files/mimiciv/2.0/hosp",
ehr_tables=["diagnoses_icd", "procedures_icd", "prescriptions"],
dev=_DEV,
)

print("stat")
mimicvi.stat()
print("info")
mimicvi.info()
mimicvi.stats()

mimic4_sample = mimicvi.set_task(drug_recommendation_mimic4_fn)
mimic4_sample = mimicvi.set_task(DrugRecommendationMIMIC4())
print(mimic4_sample[0])

return mimic4_sample
Expand All @@ -50,14 +44,10 @@ def get_dataloaders(mimic4_sample):


def train_gamenet(mimic4_sample, train_loader, val_loader):
# gamenet = GAMENet(mimicvi)
gamenet = GAMENet(mimic4_sample)
gamenet = GAMENet(dataset=mimic4_sample)

# print(gamenet.generate_ddi_adj())
trainer = Trainer(
model=gamenet,
# metrics = ["jaccard_weighted", "pr_auc_micro", "pr_auc_macro"],
# metrics = ["jaccard", "pr_auc_micro", "pr_auc_macro"],
metrics=[
"jaccard_samples",
"accuracy",
Expand All @@ -67,7 +57,6 @@ def train_gamenet(mimic4_sample, train_loader, val_loader):
"pr_auc_samples",
"f1_samples",
],
device="cuda",
exp_name="drug_recommendation",
)

Expand Down
Loading