Update Mimic4Dataset.py
Browse files- Mimic4Dataset.py +5 -7
Mimic4Dataset.py
CHANGED
@@ -10,7 +10,7 @@ from sklearn.model_selection import train_test_split
|
|
10 |
from sklearn.preprocessing import LabelEncoder
|
11 |
import yaml
|
12 |
import numpy as np
|
13 |
-
from .dataset_utils import vocab, concat_data, generate_deep, generate_ml, generate_text
|
14 |
from .task_cohort import create_cohort
|
15 |
|
16 |
|
@@ -238,7 +238,7 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
238 |
if (len(lab)!=interv):
|
239 |
verif=False
|
240 |
return verif
|
241 |
-
|
242 |
###########################################################RAW##################################################################
|
243 |
|
244 |
def _info_raw(self):
|
@@ -435,11 +435,9 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
435 |
|
436 |
df = pd.DataFrame.from_dict(dico, orient='index')
|
437 |
for i, data in df.iterrows():
|
438 |
-
dyn_df,cond_df,demo=concat_data(data,self.config.name.replace(" ","_"),self.feat_cond,self.feat_proc,self.feat_out, self.feat_chart, self.feat_meds,self.feat_lab)
|
439 |
dyn=dyn_df.copy()
|
440 |
dyn.columns=dyn.columns.droplevel(0)
|
441 |
-
#cols=dyn.columns
|
442 |
-
#time=dyn.shape[0]
|
443 |
concat_cols = [f"{col}_{t}" for t in range(dyn.shape[0]) for col in dyn.columns]
|
444 |
demo['gender']=gen_encoder.transform(demo['gender'])
|
445 |
demo['ethnicity']=eth_encoder.transform(demo['ethnicity'])
|
@@ -486,8 +484,7 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
486 |
dico = pickle.load(fp)
|
487 |
|
488 |
for key, data in dico.items():
|
489 |
-
stat, demo, meds, chart, out, proc, lab, y = generate_deep(data, self.config.name.replace(" ","_"), self.feat_cond, self.feat_proc, self.feat_out, self.feat_chart, self.feat_meds,self.feat_lab)
|
490 |
-
|
491 |
if self.verif_dim_tensor(proc, out, chart, meds, lab):
|
492 |
if self.data_icu:
|
493 |
yield int(key), {
|
@@ -542,6 +539,7 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
542 |
def _info(self):
|
543 |
self.path = self.init_cohort()
|
544 |
self.size_cond, self.size_proc, self.size_meds, self.size_out, self.size_chart, self.size_lab, eth_vocab,gender_vocab,age_vocab,ins_vocab=vocab(self.config.name.replace(" ","_"),self.feat_cond,self.feat_proc,self.feat_out,self.feat_chart,self.feat_meds,self.feat_lab)
|
|
|
545 |
if (self.encoding == 'concat' or self.encoding =='aggreg'):
|
546 |
return self._info_encoded()
|
547 |
|
|
|
10 |
from sklearn.preprocessing import LabelEncoder
|
11 |
import yaml
|
12 |
import numpy as np
|
13 |
+
from .dataset_utils import vocab, concat_data, generate_deep, generate_ml, generate_text, open_dict
|
14 |
from .task_cohort import create_cohort
|
15 |
|
16 |
|
|
|
238 |
if (len(lab)!=interv):
|
239 |
verif=False
|
240 |
return verif
|
241 |
+
|
242 |
###########################################################RAW##################################################################
|
243 |
|
244 |
def _info_raw(self):
|
|
|
435 |
|
436 |
df = pd.DataFrame.from_dict(dico, orient='index')
|
437 |
for i, data in df.iterrows():
|
438 |
+
dyn_df,cond_df,demo=concat_data(data,self.config.name.replace(" ","_"),self.feat_cond,self.feat_proc,self.feat_out, self.feat_chart, self.feat_meds,self.feat_lab,self.condDict, self.procDict, self.outDict, self.chartDict, self.medDict)
|
439 |
dyn=dyn_df.copy()
|
440 |
dyn.columns=dyn.columns.droplevel(0)
|
|
|
|
|
441 |
concat_cols = [f"{col}_{t}" for t in range(dyn.shape[0]) for col in dyn.columns]
|
442 |
demo['gender']=gen_encoder.transform(demo['gender'])
|
443 |
demo['ethnicity']=eth_encoder.transform(demo['ethnicity'])
|
|
|
484 |
dico = pickle.load(fp)
|
485 |
|
486 |
for key, data in dico.items():
|
487 |
+
stat, demo, meds, chart, out, proc, lab, y = generate_deep(data, self.config.name.replace(" ","_"), self.feat_cond, self.feat_proc, self.feat_out, self.feat_chart, self.feat_meds,self.feat_lab,self.condDict, self.procDict, self.outDict, self.chartDict, self.medDict)
|
|
|
488 |
if self.verif_dim_tensor(proc, out, chart, meds, lab):
|
489 |
if self.data_icu:
|
490 |
yield int(key), {
|
|
|
539 |
def _info(self):
|
540 |
self.path = self.init_cohort()
|
541 |
self.size_cond, self.size_proc, self.size_meds, self.size_out, self.size_chart, self.size_lab, eth_vocab,gender_vocab,age_vocab,ins_vocab=vocab(self.config.name.replace(" ","_"),self.feat_cond,self.feat_proc,self.feat_out,self.feat_chart,self.feat_meds,self.feat_lab)
|
542 |
+
self.condDict, self.procDict, self.outDict, self.chartDict, self.medDict = open_dict(self.config.name.replace(" ","_"),self.feat_cond,self.feat_proc,self.feat_out,self.feat_chart,self.feat_lab,self.feat_meds)
|
543 |
if (self.encoding == 'concat' or self.encoding =='aggreg'):
|
544 |
return self._info_encoded()
|
545 |
|