thbndi commited on
Commit
cbcf3c2
·
1 Parent(s): ea26c2d

Update Mimic4Dataset.py

Browse files
Files changed (1) hide show
  1. Mimic4Dataset.py +25 -22
Mimic4Dataset.py CHANGED
@@ -560,6 +560,8 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
560
  ###########################################################RAW##################################################################
561
 
562
  def _info_raw(self):
 
 
563
  features = datasets.Features(
564
  {
565
  "label": datasets.ClassLabel(num_classes=2,names=["0", "1"]),
@@ -722,8 +724,16 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
722
 
723
  ###########################################################ENCODED##################################################################
724
 
725
- def _info_encoded(self,X_encoded):
726
- columns = {col: self.map_dtype(X_encoded[col].dtype) for col in X_encoded.columns}
 
 
 
 
 
 
 
 
727
  features = datasets.Features(columns)
728
  return datasets.DatasetInfo(
729
  description=_DESCRIPTION,
@@ -747,6 +757,17 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
747
  yield i, row.to_dict()
748
  ######################################################DEEP###############################################################
749
  def _info_deep(self):
 
 
 
 
 
 
 
 
 
 
 
750
  features = datasets.Features(
751
  {
752
  "label": datasets.ClassLabel(num_classes=2,names=["0", "1"]),
@@ -802,29 +823,11 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
802
 
803
  #############################################################################################################################
804
  def _info(self):
805
- self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out,self.path = self.create_cohort()
806
  if self.encoding == 'onehot' :
807
- X_train_encoded=generate_split(self.path+'/train_data.pkl',self.config.name,True,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
808
- X_test_encoded=generate_split(self.path+'/test_data.pkl',self.config.name,True,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
809
- X_val_encoded=generate_split(self.path+'/val_data.pkl',self.config.name,True,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
810
-
811
- X_train_encoded.to_csv(self.path+"/X_train_encoded.csv", index=False)
812
- X_test_encoded.to_csv(self.path+"/X_test_encoded.csv", index=False)
813
- X_val_encoded.to_csv(self.path+"/X_val_encoded.csv", index=False)
814
- return self._info_encoded(X_train_encoded)
815
 
816
  elif self.encoding == 'deep' :
817
- X_train_deep = generate_split_deep(self.path+'/train_data.pkl',self.config.name,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
818
- X_test_deep = generate_split_deep(self.path+'/test_data.pkl',self.config.name,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
819
- X_val_deep = generate_split_deep(self.path+'/val_data.pkl',self.config.name,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
820
-
821
- with open(self.path+"/X_train_deep.pkl", 'wb') as f:
822
- pickle.dump(X_train_deep, f)
823
- with open(self.path+"/X_test_deep.pkl", 'wb') as f:
824
- pickle.dump(X_test_deep, f)
825
- with open(self.path+"/X_val_deep.pkl", 'wb') as f:
826
- pickle.dump(X_val_deep, f)
827
-
828
  return self._info_deep()
829
 
830
  else:
 
560
  ###########################################################RAW##################################################################
561
 
562
  def _info_raw(self):
563
+ self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out,self.path = self.create_cohort()
564
+
565
  features = datasets.Features(
566
  {
567
  "label": datasets.ClassLabel(num_classes=2,names=["0", "1"]),
 
724
 
725
  ###########################################################ENCODED##################################################################
726
 
727
+ def _info_encoded(self):
728
+ self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out,self.path = self.create_cohort()
729
+ X_train_encoded=generate_split(self.path+'/train_data.pkl',self.config.name,True,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
730
+ X_test_encoded=generate_split(self.path+'/test_data.pkl',self.config.name,True,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
731
+ X_val_encoded=generate_split(self.path+'/val_data.pkl',self.config.name,True,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
732
+
733
+ X_train_encoded.to_csv(self.path+"/X_train_encoded.csv", index=False)
734
+ X_test_encoded.to_csv(self.path+"/X_test_encoded.csv", index=False)
735
+ X_val_encoded.to_csv(self.path+"/X_val_encoded.csv", index=False)
736
+ columns = {col: self.map_dtype(X_train_encoded[col].dtype) for col in X_train_encoded.columns}
737
  features = datasets.Features(columns)
738
  return datasets.DatasetInfo(
739
  description=_DESCRIPTION,
 
757
  yield i, row.to_dict()
758
  ######################################################DEEP###############################################################
759
  def _info_deep(self):
760
+ self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out,self.path = self.create_cohort()
761
+ X_train_deep = generate_split_deep(self.path+'/train_data.pkl',self.config.name,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
762
+ X_test_deep = generate_split_deep(self.path+'/test_data.pkl',self.config.name,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
763
+ X_val_deep = generate_split_deep(self.path+'/val_data.pkl',self.config.name,self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out)
764
+
765
+ with open(self.path+"/X_train_deep.pkl", 'wb') as f:
766
+ pickle.dump(X_train_deep, f)
767
+ with open(self.path+"/X_test_deep.pkl", 'wb') as f:
768
+ pickle.dump(X_test_deep, f)
769
+ with open(self.path+"/X_val_deep.pkl", 'wb') as f:
770
+ pickle.dump(X_val_deep, f)
771
  features = datasets.Features(
772
  {
773
  "label": datasets.ClassLabel(num_classes=2,names=["0", "1"]),
 
823
 
824
  #############################################################################################################################
825
  def _info(self):
826
+
827
  if self.encoding == 'onehot' :
828
+ return self._info_encoded()
 
 
 
 
 
 
 
829
 
830
  elif self.encoding == 'deep' :
 
 
 
 
 
 
 
 
 
 
 
831
  return self._info_deep()
832
 
833
  else: