thbndi commited on
Commit
46e9839
·
1 Parent(s): b5dc2d0

Update Mimic4Dataset.py

Browse files
Files changed (1) hide show
  1. Mimic4Dataset.py +26 -10
Mimic4Dataset.py CHANGED
@@ -361,6 +361,11 @@ def generate_split_deep(path,task,feat_cond,feat_chart,feat_proc, feat_meds, fea
361
  taskf=task.replace(" ","_")
362
  for hid, data in tqdm(X.iterrows(),desc='Encoding Splits Data for '+task+' task'):
363
  stat, demo, meds, chart, out, proc, lab, y = getXY_deep(data, taskf, feat_cond, feat_proc, feat_out, feat_chart,feat_meds)
 
 
 
 
 
364
  X_dict[hid] = {'stat': stat, 'demo': demo, 'meds': meds, 'chart': chart, 'out': out, 'proc': proc, 'lab': lab, 'y': y}
365
 
366
  return X_dict
@@ -742,8 +747,19 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
742
  yield i, row.to_dict()
743
  ######################################################DEEP###############################################################
744
  def _info_deep(self,X_encoded):
745
- keys= list(set(key for item in X_encoded.values() for key in item.keys()))
746
- features = datasets.Features({key: self.map_dtype(X_encoded[key].dtype) for key in keys})
 
 
 
 
 
 
 
 
 
 
 
747
  return datasets.DatasetInfo(
748
  description=_DESCRIPTION,
749
  features=features,
@@ -774,14 +790,14 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
774
  lab=data['lab']
775
 
776
  yield int(key), {
777
- 'proc': proc_features,
778
- 'chart': chart_features,
779
- 'meds': meds_features,
780
- 'out': out_features,
781
- 'stat': cond_features,
782
- 'demo': demo,
783
- 'lab': lab,
784
- 'y': label
785
  }
786
 
787
  #############################################################################################################################
 
361
  taskf=task.replace(" ","_")
362
  for hid, data in tqdm(X.iterrows(),desc='Encoding Splits Data for '+task+' task'):
363
  stat, demo, meds, chart, out, proc, lab, y = getXY_deep(data, taskf, feat_cond, feat_proc, feat_out, feat_chart,feat_meds)
364
+ meds=np.nan_to_num(meds, copy=False)
365
+ chart=np.nan_to_num(chart, copy=False)
366
+ out=np.nan_to_num(out, copy=False)
367
+ proc=np.nan_to_num(proc, copy=False)
368
+ lab=np.nan_to_num(lab, copy=False)
369
  X_dict[hid] = {'stat': stat, 'demo': demo, 'meds': meds, 'chart': chart, 'out': out, 'proc': proc, 'lab': lab, 'y': y}
370
 
371
  return X_dict
 
747
  yield i, row.to_dict()
748
  ######################################################DEEP###############################################################
749
  def _info_deep(self,X_encoded):
750
+ features = datasets.Features(
751
+ {
752
+ "label": datasets.ClassLabel(num_classes=2,names=["0", "1"]),
753
+ "DEMO": datasets.Sequence(datasets.Value("int32")),
754
+ "COND" : datasets.Sequence(datasets.Sequence(datasets.Value("float32"))) ,
755
+ "MEDS" : datasets.Sequence(datasets.Sequence(datasets.Value("float32"))) ,
756
+ "PROC" : datasets.Sequence(datasets.Sequence(datasets.Value("float32"))) ,
757
+ "CHART" : datasets.Sequence(datasets.Sequence(datasets.Value("float32"))) ,
758
+ "OUT" : datasets.Sequence(datasets.Sequence(datasets.Value("float32"))) ,
759
+ "LAB" : datasets.Sequence(datasets.Sequence(datasets.Value("float32"))) ,
760
+
761
+ }
762
+ )
763
  return datasets.DatasetInfo(
764
  description=_DESCRIPTION,
765
  features=features,
 
790
  lab=data['lab']
791
 
792
  yield int(key), {
793
+ 'label': label,
794
+ 'DEMO': demo,
795
+ 'COND': cond_features,
796
+ 'MEDS': meds_features,
797
+ 'PROC': proc_features,
798
+ 'CHART': chart_features,
799
+ 'OUT': out_features,
800
+ 'LAB': lab,
801
  }
802
 
803
  #############################################################################################################################