-
Notifications
You must be signed in to change notification settings - Fork 0
/
formData.py
53 lines (26 loc) · 905 Bytes
/
formData.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
import _pickle as pickle
import numpy as np
update_file = './X.p'
norm_file = './norm.p'
with open(update_file, 'rb') as f:
raw_data = pickle.load(f)
norm_data[:,:,3] = np.log(norm_data[:,:,3] + 1e-7)
norm_data[:,:,5:8] = np.log(norm_data[:,:,5:8] + 1e-7)
mean = np.mean(norm_data, axis=0)
std = np.std(norm_data, axis=0) + 1e-8
norm_data = (norm_data - mean) /std
max_data = mean +1.96*std
min_data = mean - 1.96*std
norm_data = np.maximum(min_data, norm_data)
norm_data = np.minimum(norm_data, max_data)
for i in range(72):
norm_data[:,i,8] = (i%24 - 11/5)/6.922186552431729
print(norm_data[20,i,:])
all_norm = {'std':std, 'mean':mean, 'data':norm_data}
with open(norm_file, 'wb') as f:
pickle.dump(all_norm, f)
test = np.zeros(24)
for i in range(24):
test[i] = i
print(np.mean(test))
print(np.std(test))