Update Mimic4Dataset.py
Browse files- Mimic4Dataset.py +14 -4
Mimic4Dataset.py
CHANGED
@@ -536,7 +536,11 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
536 |
self.config_path = kwargs.pop("config_path",None)
|
537 |
self.test_size = kwargs.pop("test_size",0.2)
|
538 |
self.val_size = kwargs.pop("val_size",0.1)
|
539 |
-
|
|
|
|
|
|
|
|
|
540 |
super().__init__(**kwargs)
|
541 |
|
542 |
|
@@ -656,8 +660,8 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
656 |
config = self.config_path.split('/')[-1]
|
657 |
|
658 |
#####################create task cohort
|
659 |
-
|
660 |
-
|
661 |
|
662 |
#####################Split data into train, test and val
|
663 |
with open(data_dir, 'rb') as fp:
|
@@ -892,7 +896,7 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
892 |
demo['insurance']=ins_encoder.transform(demo['insurance'])
|
893 |
label = data['label']
|
894 |
demo=demo.drop(['label'],axis=1)
|
895 |
-
X= getXY(dyn_df,cond_df,demo,concat_cols,
|
896 |
X=X.values.tolist()[0]
|
897 |
yield int(i), {
|
898 |
"label": label,
|
@@ -946,6 +950,9 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
946 |
|
947 |
if self.encoding == 'onehot' :
|
948 |
return self._info_encoded()
|
|
|
|
|
|
|
949 |
|
950 |
elif self.encoding == 'deep' :
|
951 |
return self._info_deep()
|
@@ -968,6 +975,9 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
968 |
if self.encoding == 'onehot' :
|
969 |
yield from self._generate_examples_encoded(filepath)
|
970 |
|
|
|
|
|
|
|
971 |
elif self.encoding == 'deep' :
|
972 |
yield from self._generate_examples_deep(filepath)
|
973 |
else :
|
|
|
536 |
self.config_path = kwargs.pop("config_path",None)
|
537 |
self.test_size = kwargs.pop("test_size",0.2)
|
538 |
self.val_size = kwargs.pop("val_size",0.1)
|
539 |
+
self.generate_cohort = kwargs.pop("generate_cohort",True)
|
540 |
+
if self.encoding == 'onehot':
|
541 |
+
self.concat = True
|
542 |
+
else:
|
543 |
+
self.concat = False
|
544 |
super().__init__(**kwargs)
|
545 |
|
546 |
|
|
|
660 |
config = self.config_path.split('/')[-1]
|
661 |
|
662 |
#####################create task cohort
|
663 |
+
if self.generate_cohort:
|
664 |
+
task_cohort(self.config.name.replace(" ","_"),self.mimic_path,config)
|
665 |
|
666 |
#####################Split data into train, test and val
|
667 |
with open(data_dir, 'rb') as fp:
|
|
|
896 |
demo['insurance']=ins_encoder.transform(demo['insurance'])
|
897 |
label = data['label']
|
898 |
demo=demo.drop(['label'],axis=1)
|
899 |
+
X= getXY(dyn_df,cond_df,demo,concat_cols,self.concat)
|
900 |
X=X.values.tolist()[0]
|
901 |
yield int(i), {
|
902 |
"label": label,
|
|
|
950 |
|
951 |
if self.encoding == 'onehot' :
|
952 |
return self._info_encoded()
|
953 |
+
|
954 |
+
elif self.encoding == 'aggreg' :
|
955 |
+
return self._info_encoded()
|
956 |
|
957 |
elif self.encoding == 'deep' :
|
958 |
return self._info_deep()
|
|
|
975 |
if self.encoding == 'onehot' :
|
976 |
yield from self._generate_examples_encoded(filepath)
|
977 |
|
978 |
+
elif self.encoding == 'aggreg' :
|
979 |
+
yield from self._generate_examples_encoded(filepath)
|
980 |
+
|
981 |
elif self.encoding == 'deep' :
|
982 |
yield from self._generate_examples_deep(filepath)
|
983 |
else :
|