-
Notifications
You must be signed in to change notification settings - Fork 0
/
mimic_respiratory_failure.py
47 lines (38 loc) · 1.26 KB
/
mimic_respiratory_failure.py
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
import pdb
import numpy as np
path = 'mimic_respiratory_failure/'
def load_data(tasks=None):
if tasks == None:
tasks = [0,1,2,3,4,5,6]
inp = np.load(path+'x.npy')
label = np.load(path+'y.npy')
label = label[:,tasks]
index = range(len(label))
# np.random.shuffle(index)
train = int(len(label)*0.7)
valid = int(len(label)*0.85)
train_x = []
train_y = []
for i in range(train):
train_x.append(inp[index[i]])
train_y.append(label[index[i]])
train_x = np.array(train_x,np.float32)
train_y = np.array(train_y,np.float32)
valid_x = []
valid_y = []
for i in range(train,valid):
valid_x.append(inp[index[i]])
valid_y.append(label[index[i]])
valid_x = np.array(valid_x,np.float32)
valid_y = np.array(valid_y,np.float32)
eval_x = []
eval_y = []
for i in range(valid,len(index)):
eval_x.append(inp[index[i]])
eval_y.append(label[index[i]])
eval_x = np.array(eval_x,np.float32)
eval_y = np.array(eval_y,np.float32)
return train_x, train_y, valid_x, valid_y, eval_x, eval_y, train_x.shape[2], train_x.shape[1], len(tasks)
if __name__ == '__main__':
train_x,train_y,valid_x,valid_y,eval_x,eval_y, _,_,_ = load_data()
pdb.set_trace()