Update Mimic4Dataset.py
Browse files- Mimic4Dataset.py +37 -37
Mimic4Dataset.py
CHANGED
@@ -144,41 +144,41 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
144 |
|
145 |
|
146 |
def _generate_examples(self, filepath):
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
|
|
|
144 |
|
145 |
|
146 |
def _generate_examples(self, filepath):
|
147 |
+
with open(filepath, 'rb') as fp:
|
148 |
+
dataDic = pickle.load(fp)
|
149 |
+
for hid, data in dataDic.items():
|
150 |
+
proc_features = data['Proc']
|
151 |
+
chart_features = data['Chart']
|
152 |
+
meds_features = data['Med']
|
153 |
+
out_features = data['Out']
|
154 |
+
cond_features = data['Cond']['fids']
|
155 |
+
eth= data['ethnicity']
|
156 |
+
age = data['age']
|
157 |
+
gender = data['gender']
|
158 |
+
label = data['label']
|
159 |
+
|
160 |
+
# Convert integer PROC feature to dictionary
|
161 |
+
if isinstance(proc_features, int):
|
162 |
+
proc_features = {proc_features: []}
|
163 |
+
if isinstance(out_features, int):
|
164 |
+
proc_features = {out_features: []}
|
165 |
+
|
166 |
+
yield hid, {
|
167 |
+
"gender" : gender,
|
168 |
+
"ethnicity" : eth,
|
169 |
+
"age" : age,
|
170 |
+
"MEDS" : {
|
171 |
+
"signal" : meds_features['signal'],
|
172 |
+
"rate" : meds_features['rate'],
|
173 |
+
"amount" : meds_features['amount']
|
174 |
+
},
|
175 |
+
"PROC" : proc_features,
|
176 |
+
"CHART" : {
|
177 |
+
"signal" : chart_features['signal'],
|
178 |
+
"val" : chart_features['val']
|
179 |
+
},
|
180 |
+
"OUT" : out_features,
|
181 |
+
"COND" : cond_features,
|
182 |
+
"label" : label
|
183 |
+
}
|
184 |
|