Update Mimic4Dataset.py
Browse files- Mimic4Dataset.py +42 -8
Mimic4Dataset.py
CHANGED
@@ -60,10 +60,26 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
60 |
"cond" : datasets.Value("string"),
|
61 |
"value" : datasets.Value("int32")
|
62 |
}),
|
63 |
-
"MEDS": datasets.Sequence(
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
"label": datasets.ClassLabel(names=["0", "1"]),
|
68 |
}
|
69 |
)
|
@@ -130,7 +146,13 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
130 |
proc_dict = proc.iloc[0].to_dict()
|
131 |
chart_dict = chart.iloc[0].to_dict()
|
132 |
out_dict = out.iloc[0].to_dict()
|
|
|
133 |
stat2 = {'cond': list(stat_dict.keys()), 'value': list(stat_dict.values())}
|
|
|
|
|
|
|
|
|
|
|
134 |
#get stay_id which is the name of the folder containing the files
|
135 |
stay_id = int(demographic_file.split("/")[-2])
|
136 |
#get the label
|
@@ -141,10 +163,22 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
141 |
"ethnicity" : demo_dict['ethnicity'],
|
142 |
"insurance" : demo_dict['insurance'],
|
143 |
"age" : demo_dict['Age'],
|
144 |
-
"MEDS" :
|
145 |
-
|
146 |
-
|
147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
"COND" : {
|
149 |
"cond" : stat2['cond'],
|
150 |
"value" : stat2['value']
|
|
|
60 |
"cond" : datasets.Value("string"),
|
61 |
"value" : datasets.Value("int32")
|
62 |
}),
|
63 |
+
"MEDS": datasets.Sequence(
|
64 |
+
{
|
65 |
+
"meds" : datasets.Value("string"),
|
66 |
+
"value" : datasets.Value("int32")
|
67 |
+
}),
|
68 |
+
"PROC": datasets.Sequence(
|
69 |
+
{
|
70 |
+
"proc" : datasets.Value("string"),
|
71 |
+
"value" : datasets.Value("int32")
|
72 |
+
}),
|
73 |
+
"CHART": datasets.Sequence(
|
74 |
+
{
|
75 |
+
"chart" : datasets.Value("string"),
|
76 |
+
"value" : datasets.Value("int32")
|
77 |
+
}),
|
78 |
+
"OUT": datasets.Sequence(
|
79 |
+
{
|
80 |
+
"out" : datasets.Value("string"),
|
81 |
+
"value" : datasets.Value("int32")
|
82 |
+
}),
|
83 |
"label": datasets.ClassLabel(names=["0", "1"]),
|
84 |
}
|
85 |
)
|
|
|
146 |
proc_dict = proc.iloc[0].to_dict()
|
147 |
chart_dict = chart.iloc[0].to_dict()
|
148 |
out_dict = out.iloc[0].to_dict()
|
149 |
+
|
150 |
stat2 = {'cond': list(stat_dict.keys()), 'value': list(stat_dict.values())}
|
151 |
+
meds = {'meds': list(meds_dict.keys()), 'value': list(meds_dict.values())}
|
152 |
+
proc = {'proc': list(proc_dict.keys()), 'value': list(proc_dict.values())}
|
153 |
+
chart = {'chart': list(chart_dict.keys()), 'value': list(chart_dict.values())}
|
154 |
+
out = {'out': list(out_dict.keys()), 'value': list(out_dict.values())}
|
155 |
+
|
156 |
#get stay_id which is the name of the folder containing the files
|
157 |
stay_id = int(demographic_file.split("/")[-2])
|
158 |
#get the label
|
|
|
163 |
"ethnicity" : demo_dict['ethnicity'],
|
164 |
"insurance" : demo_dict['insurance'],
|
165 |
"age" : demo_dict['Age'],
|
166 |
+
"MEDS" : {
|
167 |
+
"meds" : stat2['cond'],
|
168 |
+
"value" : stat2['value']
|
169 |
+
},
|
170 |
+
"PROC" : {
|
171 |
+
"proc" : stat2['cond'],
|
172 |
+
"value" : stat2['value']
|
173 |
+
},
|
174 |
+
"CHART" : {
|
175 |
+
"chart" : stat2['cond'],
|
176 |
+
"value" : stat2['value']
|
177 |
+
},
|
178 |
+
"OUT" : {
|
179 |
+
"out" : stat2['cond'],
|
180 |
+
"value" : stat2['value']
|
181 |
+
},
|
182 |
"COND" : {
|
183 |
"cond" : stat2['cond'],
|
184 |
"value" : stat2['value']
|