-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreparation.py
70 lines (41 loc) · 1.58 KB
/
preparation.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
import numpy as np
import sys
from sklearn import preprocessing
def standardization_SVL(train_data, test_data, scale_name):
if scale_name == "0-1scale":
min_max_scaler = preprocessing.MinMaxScaler()
train_data_std = min_max_scaler.fit_transform(train_data)
test_data_std = min_max_scaler.fit_transform(test_data)
elif scale_name == "z-score":
sc = preprocessing.StandardScaler()
sc.fit(train_data)
train_data_std = sc.transform(train_data)
test_data_std = sc.transform(test_data)
else:
print("ERROR:preprocessing")
# sys.exit()
return train_data_std,test_data_std
def standardization_rule3(train_data, test_data):
sc = preprocessing.StandardScaler()
sc.fit(train_data)
train_data_std = sc.transform(train_data)
test_data_std = sc.transform(test_data)
return train_data_std, test_data_std
def standardization_rule4(train_data, test_data):
sc = preprocessing.StandardScaler()
sc.fit(test_data)
train_data_std = sc.transform(train_data)
test_data_std = sc.transform(test_data)
return train_data_std, test_data_std
def standardization(train_data, scale_name):
if scale_name == "0-1scale":
min_max_scaler = preprocessing.MinMaxScaler()
train_data_std = min_max_scaler.fit_transform(train_data)
elif scale_name == "z-score":
sc = preprocessing.StandardScaler()
sc.fit(train_data)
train_data_std = sc.transform(train_data)
else:
print("ERROR:preprocessing")
# sys.exit()
return train_data_std