-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_hospitalization.py
68 lines (65 loc) · 2 KB
/
data_hospitalization.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import numpy as np
import pandas as pd
correction = 0
direction = 'data_3_both_gender'
file_name = ''
# df=pd.read_csv("data_v123.csv")
df=pd.read_excel("data.xlsx")
df=df.sample(frac=1,random_state=13)
df=df.iloc[np.asarray(~np.isnan(df.iloc[:, 17+correction])),:]
# df = df.iloc[np.asarray(df.iloc[:,1+correction] == "M"),:]
X = df.iloc[:,20+correction:]
Diagnosis = []
list = ['M-SZ', 'M-SZA', 'M-BP', 'F-SZA', 'F-MDD', 'F-BP', 'M-MDD', 'F-SZ','F-PTSD', 'M-PTSD', 'M-PSYCH', 'M-MOOD']
for d in df.iloc[:,4+correction]:
Diagnosis.append(list.index(d))
# X['Number of All Future Hospitalizations for Anxiety'] = df.iloc[:,17-1]
# X['Time in Days to Hospitalization'] = df.iloc[:,17+correction]
X['Diagnosis'] = Diagnosis
X_np = np.asarray(X)
X_reduced = np.delete(X_np,[9, 7, 44, 94, 78, 17, 86, 10, 40, 34, 65, 90, 0, 5, 35, 58, 71, 1, 3, 21, 36, 54, 62, 64, 11, 18, 38, 48, 51, 60],axis=1)
np.save(direction+'/data'+file_name+'/X', X)
np.save(direction+'/data'+file_name+'/X_reduced', X_reduced)
print(X[0:10])
y = df.iloc[:,17+correction]
print(y[0:10])
np.save(direction+'/data'+file_name+'/Time_in_Days_to_Hospitalization', y)
# y=df.iloc[:, 16+correction]
# y=y.values
# ynew=[]
# for i in y:
# if i >0:
# ynew.append(1)
# else:
# ynew.append(0)
# np.save(direction+'/data_number_of_all_future'+file_name+'/trait_all_future_hospitalizations', ynew)
# print(ynew[0:10])
#
#
#
# y=df.iloc[:, 7+correction]
# y=y.values
# ynew=[]
# for i in y:
# if i >60:
# ynew.append(1)
# elif i<40 :
# ynew.append(0)
# else:
# ynew.append(-1)
# np.save(direction+'/data_number_of_all_future'+file_name+'/state_high_anxiety', ynew)
# print(ynew[0:10])
#
# y=df.iloc[:, 8+correction]
# y=y.values
# ynew=[]
# for i in y:
# if i >60:
# ynew.append(1)
# elif i < 30:
# ynew.append(0)
# else:
# ynew.append(-1)
# np.save(direction+'/data_number_of_all_future'+file_name+'/state_clinical_anxiety', ynew)
# print(ynew[0:10])
# print('End')