Update data_generation_icu_modify.py
Browse files- data_generation_icu_modify.py +13 -13
data_generation_icu_modify.py
CHANGED
|
@@ -21,8 +21,8 @@ class Generator():
|
|
| 21 |
self.impute=impute
|
| 22 |
self.task = task
|
| 23 |
self.data = self.generate_adm()
|
| 24 |
-
if not os.path.exists("./data/dict/"+self.
|
| 25 |
-
os.makedirs("./data/dict/"+self.
|
| 26 |
print("[ READ COHORT ]")
|
| 27 |
|
| 28 |
self.generate_feat()
|
|
@@ -529,53 +529,53 @@ class Generator():
|
|
| 529 |
######SAVE DICTIONARIES##############
|
| 530 |
metaDic={'Cond':{},'Proc':{},'Med':{},'Out':{},'Chart':{},'LOS':{}}
|
| 531 |
metaDic['LOS']=los
|
| 532 |
-
with open("./data/dict/dataDic", 'wb') as fp:
|
| 533 |
pickle.dump(dataDic, fp)
|
| 534 |
|
| 535 |
-
with open("./data/dict/hadmDic", 'wb') as fp:
|
| 536 |
pickle.dump(self.hids, fp)
|
| 537 |
|
| 538 |
-
with open("./data/dict/ethVocab", 'wb') as fp:
|
| 539 |
pickle.dump(list(self.data['ethnicity'].unique()), fp)
|
| 540 |
self.eth_vocab = self.data['ethnicity'].nunique()
|
| 541 |
|
| 542 |
-
with open("./data/dict/ageVocab", 'wb') as fp:
|
| 543 |
pickle.dump(list(self.data['Age'].unique()), fp)
|
| 544 |
self.age_vocab = self.data['Age'].nunique()
|
| 545 |
|
| 546 |
-
with open("./data/dict/insVocab", 'wb') as fp:
|
| 547 |
pickle.dump(list(self.data['insurance'].unique()), fp)
|
| 548 |
self.ins_vocab = self.data['insurance'].nunique()
|
| 549 |
|
| 550 |
if(self.feat_med):
|
| 551 |
-
with open("./data/dict/medVocab", 'wb') as fp:
|
| 552 |
pickle.dump(list(meds['itemid'].unique()), fp)
|
| 553 |
self.med_vocab = meds['itemid'].nunique()
|
| 554 |
metaDic['Med']=self.med_per_adm
|
| 555 |
|
| 556 |
if(self.feat_out):
|
| 557 |
-
with open("./data/dict/outVocab", 'wb') as fp:
|
| 558 |
pickle.dump(list(out['itemid'].unique()), fp)
|
| 559 |
self.out_vocab = out['itemid'].nunique()
|
| 560 |
metaDic['Out']=self.out_per_adm
|
| 561 |
|
| 562 |
if(self.feat_chart):
|
| 563 |
-
with open("./data/dict/chartVocab", 'wb') as fp:
|
| 564 |
pickle.dump(list(chart['itemid'].unique()), fp)
|
| 565 |
self.chart_vocab = chart['itemid'].nunique()
|
| 566 |
metaDic['Chart']=self.chart_per_adm
|
| 567 |
|
| 568 |
if(self.feat_cond):
|
| 569 |
-
with open("./data/dict/condVocab", 'wb') as fp:
|
| 570 |
pickle.dump(list(self.cond['new_icd_code'].unique()), fp)
|
| 571 |
self.cond_vocab = self.cond['new_icd_code'].nunique()
|
| 572 |
metaDic['Cond']=self.cond_per_adm
|
| 573 |
|
| 574 |
if(self.feat_proc):
|
| 575 |
-
with open("./data/dict/procVocab", 'wb') as fp:
|
| 576 |
pickle.dump(list(proc['itemid'].unique()), fp)
|
| 577 |
self.proc_vocab = proc['itemid'].nunique()
|
| 578 |
metaDic['Proc']=self.proc_per_adm
|
| 579 |
|
| 580 |
-
with open("./data/dict/metaDic", 'wb') as fp:
|
| 581 |
pickle.dump(metaDic, fp)
|
|
|
|
| 21 |
self.impute=impute
|
| 22 |
self.task = task
|
| 23 |
self.data = self.generate_adm()
|
| 24 |
+
if not os.path.exists("./data/dict/"+self.task):
|
| 25 |
+
os.makedirs("./data/dict/"+self.task)
|
| 26 |
print("[ READ COHORT ]")
|
| 27 |
|
| 28 |
self.generate_feat()
|
|
|
|
| 529 |
######SAVE DICTIONARIES##############
|
| 530 |
metaDic={'Cond':{},'Proc':{},'Med':{},'Out':{},'Chart':{},'LOS':{}}
|
| 531 |
metaDic['LOS']=los
|
| 532 |
+
with open("./data/dict/"+self.task+"/dataDic", 'wb') as fp:
|
| 533 |
pickle.dump(dataDic, fp)
|
| 534 |
|
| 535 |
+
with open("./data/dict/"+self.task+"/hadmDic", 'wb') as fp:
|
| 536 |
pickle.dump(self.hids, fp)
|
| 537 |
|
| 538 |
+
with open("./data/dict/"+self.task+"/ethVocab", 'wb') as fp:
|
| 539 |
pickle.dump(list(self.data['ethnicity'].unique()), fp)
|
| 540 |
self.eth_vocab = self.data['ethnicity'].nunique()
|
| 541 |
|
| 542 |
+
with open("./data/dict/"+self.task+"/ageVocab", 'wb') as fp:
|
| 543 |
pickle.dump(list(self.data['Age'].unique()), fp)
|
| 544 |
self.age_vocab = self.data['Age'].nunique()
|
| 545 |
|
| 546 |
+
with open("./data/dict/"+self.task+"/insVocab", 'wb') as fp:
|
| 547 |
pickle.dump(list(self.data['insurance'].unique()), fp)
|
| 548 |
self.ins_vocab = self.data['insurance'].nunique()
|
| 549 |
|
| 550 |
if(self.feat_med):
|
| 551 |
+
with open("./data/dict/"+self.task+"/medVocab", 'wb') as fp:
|
| 552 |
pickle.dump(list(meds['itemid'].unique()), fp)
|
| 553 |
self.med_vocab = meds['itemid'].nunique()
|
| 554 |
metaDic['Med']=self.med_per_adm
|
| 555 |
|
| 556 |
if(self.feat_out):
|
| 557 |
+
with open("./data/dict/"+self.task+"/outVocab", 'wb') as fp:
|
| 558 |
pickle.dump(list(out['itemid'].unique()), fp)
|
| 559 |
self.out_vocab = out['itemid'].nunique()
|
| 560 |
metaDic['Out']=self.out_per_adm
|
| 561 |
|
| 562 |
if(self.feat_chart):
|
| 563 |
+
with open("./data/dict/"+self.task+"/chartVocab", 'wb') as fp:
|
| 564 |
pickle.dump(list(chart['itemid'].unique()), fp)
|
| 565 |
self.chart_vocab = chart['itemid'].nunique()
|
| 566 |
metaDic['Chart']=self.chart_per_adm
|
| 567 |
|
| 568 |
if(self.feat_cond):
|
| 569 |
+
with open("./data/dict/"+self.task+"/condVocab", 'wb') as fp:
|
| 570 |
pickle.dump(list(self.cond['new_icd_code'].unique()), fp)
|
| 571 |
self.cond_vocab = self.cond['new_icd_code'].nunique()
|
| 572 |
metaDic['Cond']=self.cond_per_adm
|
| 573 |
|
| 574 |
if(self.feat_proc):
|
| 575 |
+
with open("./data/dict/"+self.task+"/procVocab", 'wb') as fp:
|
| 576 |
pickle.dump(list(proc['itemid'].unique()), fp)
|
| 577 |
self.proc_vocab = proc['itemid'].nunique()
|
| 578 |
metaDic['Proc']=self.proc_per_adm
|
| 579 |
|
| 580 |
+
with open("./data/dict/"+self.task+"/metaDic", 'wb') as fp:
|
| 581 |
pickle.dump(metaDic, fp)
|