-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstance_num_table.py
More file actions
51 lines (33 loc) · 1.99 KB
/
instance_num_table.py
File metadata and controls
51 lines (33 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import sys
import numpy as np
import pandas as pd
import constants as constants
import features.mimic3_function as mimic3_myfunc
instances = []
current_data = constants.exclusion_rules[0]
Root_Data = constants.DATA_processed + current_data
Root_Data, _, Output_predictions, Output_results = mimic3_myfunc.folders(current_data, model=constants.MODELS[0])
purpose = 'test'
Data_Dir= Root_Data + purpose+'/'
print(Data_Dir)
for x,y in constants.xy_pairs:
a2,k=0,5
for a1 in constants.T_list:
labels1=np.load(Data_Dir + 'label_' + str(x) + '_' + str(y) + '_' + str(a1) + constants.FEATURES[0][1:] + '.npy')
labels2=np.load(Data_Dir + 'label_' + str(x) + '_' + str(y) + '_' + str(a1) + constants.FEATURES[1][1:] + '.npy')
labels3=np.load(Data_Dir + 'label_' + str(x) + '_' + str(y) + '_' + str(a1) + constants.FEATURES[2][1:] + '.npy')
if a1==12:
# instances.append([str(x)+','+str(y),'-',str(len(labels1))+'&',\
# str(len(labels2))+'&',len(labels3)])
instances.append([str(x)+','+str(y),'-',len(labels1),\
len(labels2),len(labels3)])
sepsis_instance_number1=len(np.where(labels1==1)[0])
sepsis_instance_number2=len(np.where(labels2==1)[0])
sepsis_instance_number3=len(np.where(labels3==1)[0])
instances.append([str(x)+','+str(y),a1,sepsis_instance_number1,\
sepsis_instance_number2,sepsis_instance_number3])
# instances.append([str(x)+','+str(y),a1,str(sepsis_instance_number1)+'&',\
# str(sepsis_instance_number2)+'&',sepsis_instance_number3])
instances_df = pd.DataFrame(instances, columns=['x,y','a1', 'instance'+constants.FEATURES[0][1:],\
'instance'+constants.FEATURES[1][1:],'instance'+constants.FEATURES[2][1:]])
instances_df.to_csv(Data_Dir+'instance_number.csv')