Comments (5)
Yes, I'd like to help. Could you share with us what functions you have called?
from pyhealth.
Yes, I'd like to help. Could you share with us what functions you have called?
Thanks for your reply.
from pyhealth.datasets import eICUDataset
base_dataset = eICUDataset(
root="./eicu-crd/2.0",
tables=["diagnosis", "medication", "physicalExam"],
dev=True,
refresh_cache=False,
)
sample_dataset = base_dataset.set_task(task_fn=drug_recommendation_eicu_fn)
sample_dataset.stat()
print(sample_dataset.available_keys)
the error is from:
sample_dataset = base_dataset.set_task(task_fn=drug_recommendation_eicu_fn)
from pyhealth.
Thanks for your patience. I just found the issue. We have a typo in drug_recommendation_eicu_fn
in the current package version. Could you please use the following function to replace (not import from pyhealth.tasks, but directly define the function and use it):
def drug_recommendation_eicu_fn(patient):
samples = []
for i in range(len(patient)):
visit = patient[i]
conditions = visit.get_code_list(table="diagnosis")
procedures = visit.get_code_list(table="physicalExam")
drugs = visit.get_code_list(table="medication")
# exclude: visits without condition, procedure, or drug code
if len(conditions) * len(procedures) * len(drugs) == 0:
continue
# TODO: should also exclude visit with age < 18
samples.append(
{
"visit_id": visit.visit_id,
"patient_id": patient.patient_id,
"conditions": conditions,
"procedures": procedures,
"drugs": drugs,
"drugs_all": drugs,
}
)
# exclude: patients with less than 2 visit
if len(samples) < 2:
return []
# add history
samples[0]["conditions"] = [samples[0]["conditions"]]
samples[0]["procedures"] = [samples[0]["procedures"]]
samples[0]["drugs_all"] = [samples[0]["drugs_all"]]
for i in range(1, len(samples)):
samples[i]["conditions"] = samples[i - 1]["conditions"] + [
samples[i]["conditions"]
]
samples[i]["procedures"] = samples[i - 1]["procedures"] + [
samples[i]["procedures"]
]
samples[i]["drugs_all"] = samples[i - 1]["drugs_all"] + [
samples[i]["drugs_all"]
]
return samples
So, this new function is almost the same as the one that you have imported. The only difference is that in the second to last line:
samples[i]["drugs"] = samples[i - 1]["drugs_all"] + [
samples[i]["drugs_all"]
]
is changed into
samples[i]["drugs_all"] = samples[i - 1]["drugs_all"] + [
samples[i]["drugs_all"]
]
from pyhealth.
BTW, the task function is really just an example of how we define healthcare tasks. You can follow the pattern and modify for your own purpose.
from pyhealth.
BTW, the task function is really just an example of how we define healthcare tasks. You can follow the pattern and modify for your own purpose.
It works! Many thanks!!!
from pyhealth.
Related Issues (20)
- pyhealth.calib.calibration.
- KeyError: 'logit' HOT 3
- How to use any of model for mimic-iii code prediction? HOT 1
- Entering deadlock when parsing prescriptions HOT 9
- Hello, the question about repositorie "Pandarallel" HOT 3
- Add contributor list (tmp2) HOT 6
- Add contributor list (tmp3)
- Bug in GAMNET HOT 1
- Cannot download 'https://storage.googleapis.com/pyhealth/resource/NDC_to_ATC.csv' HOT 5
- question about MIMIC-III in drug recommendation task HOT 4
- The results obtained with pyhealth are much lower than in the paper. HOT 6
- The results of SafeDrug model differ significantly from those in the paper. HOT 4
- Performance of SafeDrug and Molerec HOT 4
- a question about metrics HOT 1
- wrong code in pyhealth\metrics\drug_recommendation.py HOT 1
- pip install version HOT 1
- Does the inner map cotains all the icd code id? HOT 5
- sequential_drug_recommendation HOT 4
- a question about ddi rate HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyhealth.