thbndi commited on
Commit
80447c9
·
1 Parent(s): 25874fd

Update Mimic4Dataset.py

Browse files
Files changed (1) hide show
  1. Mimic4Dataset.py +9 -9
Mimic4Dataset.py CHANGED
@@ -356,7 +356,7 @@ def getXY_deep(data,task,feat_cond,feat_proc,feat_out,feat_chart,feat_meds):
356
  charts = charts.unsqueeze(0)
357
  charts = torch.tensor(charts)
358
  charts = charts.type(torch.LongTensor)
359
- chart=charts
360
  ####################""
361
 
362
  keys=dyn.columns.levels[0]
@@ -387,7 +387,7 @@ def getXY_deep(data,task,feat_cond,feat_proc,feat_out,feat_chart,feat_meds):
387
  proc=dyn_df[k].squeeze(0)
388
  if keys[k]=='LAB':
389
  lab=dyn_df[k].squeeze(0)
390
-
391
  stat=cond_df
392
  stat = stat.to_numpy()
393
  stat = torch.tensor(stat)
@@ -598,7 +598,7 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
598
  self.val_size = kwargs.pop("val_size",0.1)
599
  self.generate_cohort = kwargs.pop("generate_cohort",True)
600
 
601
- if self.encoding == 'onehot':
602
  self.concat = True
603
  else:
604
  self.concat = False
@@ -911,7 +911,7 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
911
  features = datasets.Features(
912
  {
913
  "label": datasets.ClassLabel(num_classes=2,names=["0", "1"]),
914
- "onehot" : datasets.Sequence(datasets.Value("float32")),
915
  }
916
  )
917
  return datasets.DatasetInfo(
@@ -962,7 +962,7 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
962
  X=X.values.tolist()[0]
963
  yield int(i), {
964
  "label": label,
965
- "onehot": X,
966
  }
967
  ######################################################DEEP###############################################################
968
  def _info_deep(self):
@@ -1011,13 +1011,13 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
1011
  self.path = self.create_cohort()
1012
  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,False)
1013
 
1014
- if self.encoding == 'onehot' :
1015
  return self._info_encoded()
1016
 
1017
  elif self.encoding == 'aggreg' :
1018
  return self._info_encoded()
1019
 
1020
- elif self.encoding == 'deep' :
1021
  return self._info_deep()
1022
 
1023
  else:
@@ -1035,13 +1035,13 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
1035
 
1036
  def _generate_examples(self, filepath):
1037
 
1038
- if self.encoding == 'onehot' :
1039
  yield from self._generate_examples_encoded(filepath)
1040
 
1041
  elif self.encoding == 'aggreg' :
1042
  yield from self._generate_examples_encoded(filepath)
1043
 
1044
- elif self.encoding == 'deep' :
1045
  yield from self._generate_examples_deep(filepath)
1046
  else :
1047
  yield from self._generate_examples_raw(filepath)
 
356
  charts = charts.unsqueeze(0)
357
  charts = torch.tensor(charts)
358
  charts = charts.type(torch.LongTensor)
359
+
360
  ####################""
361
 
362
  keys=dyn.columns.levels[0]
 
387
  proc=dyn_df[k].squeeze(0)
388
  if keys[k]=='LAB':
389
  lab=dyn_df[k].squeeze(0)
390
+ chart=charts
391
  stat=cond_df
392
  stat = stat.to_numpy()
393
  stat = torch.tensor(stat)
 
598
  self.val_size = kwargs.pop("val_size",0.1)
599
  self.generate_cohort = kwargs.pop("generate_cohort",True)
600
 
601
+ if self.encoding == 'concat':
602
  self.concat = True
603
  else:
604
  self.concat = False
 
911
  features = datasets.Features(
912
  {
913
  "label": datasets.ClassLabel(num_classes=2,names=["0", "1"]),
914
+ "features" : datasets.Sequence(datasets.Value("float32")),
915
  }
916
  )
917
  return datasets.DatasetInfo(
 
962
  X=X.values.tolist()[0]
963
  yield int(i), {
964
  "label": label,
965
+ "features": X,
966
  }
967
  ######################################################DEEP###############################################################
968
  def _info_deep(self):
 
1011
  self.path = self.create_cohort()
1012
  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,False)
1013
 
1014
+ if self.encoding == 'concat' :
1015
  return self._info_encoded()
1016
 
1017
  elif self.encoding == 'aggreg' :
1018
  return self._info_encoded()
1019
 
1020
+ elif self.encoding == 'tensor' :
1021
  return self._info_deep()
1022
 
1023
  else:
 
1035
 
1036
  def _generate_examples(self, filepath):
1037
 
1038
+ if self.encoding == 'concat' :
1039
  yield from self._generate_examples_encoded(filepath)
1040
 
1041
  elif self.encoding == 'aggreg' :
1042
  yield from self._generate_examples_encoded(filepath)
1043
 
1044
+ elif self.encoding == 'tensor' :
1045
  yield from self._generate_examples_deep(filepath)
1046
  else :
1047
  yield from self._generate_examples_raw(filepath)