-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_data.py
More file actions
75 lines (67 loc) · 1.66 KB
/
process_data.py
File metadata and controls
75 lines (67 loc) · 1.66 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import pandas as pd
from people import People
df = pd.read_csv('C:/Users/zjy/Desktop/Final_dataset_covid19 - Copy.csv')
num_features = [
'age_quantile',
'covid19_Res',
'hemoglobin',
'platelets',
'MPV',
'RBC',
'lymphocytes',
'MCHC',
'leukocytes',
'basophils',
'MCH',
'eosinophils',
'MCV',
'monocytes',
'RDW',
'detection_coronaviridae',
'detection_orthomyxoviridae',
'detection_paramyxoviridae',
'detection_picornaviridae',
'detection_pneumoviridae'
]
number_fea = [
'age_quantile',
'detection_coronaviridae',
'detection_orthomyxoviridae',
'detection_paramyxoviridae',
'detection_picornaviridae',
'detection_pneumoviridae'
]
float_features = [
'hemoglobin',
'platelets',
'MPV',
'RBC',
'lymphocytes',
'MCHC',
'leukocytes',
'basophils',
'MCH',
'eosinophils',
'MCV',
'monocytes',
'RDW',
]
def make_people(sl):
return People(str(sl[0]), sl[1], str(sl[2]), str(sl[3]), str(sl[4]), str(sl[5]), str(sl[6]), str(sl[7]), str(sl[8]),
str(sl[9]), str(sl[10]), str(sl[11]), str(sl[12]), str(sl[13]), str(sl[14]), str(sl[15]), sl[16],
sl[17], sl[18], sl[19])
def processing_data():
ll = df.values.tolist()
result = []
for i in range(df.shape[0]):
pp = make_people(ll[i])
result.append(pp)
return result
def pre_precess_for_model(ll):
df = pd.DataFrame(ll, columns=num_features)
for i in number_fea:
df[[i]] = df[[i]].astype('float')
df[[i]] = df[[i]].astype('int')
for i in float_features:
df[[i]] = df[[i]].astype('float')
return df