-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpreprocess.py
31 lines (24 loc) · 1.07 KB
/
preprocess.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
import numpy as np
# normalization
full_data = np.loadtxt(fname='./datasets/CMAPSSData/train_FD004.txt', dtype=np.float32)
full_test = np.loadtxt(fname='./datasets/CMAPSSData/test_FD004.txt', dtype=np.float32)
# engineID and working time cycle, no need to norm
prefix_data = full_data[:, [0, 1]]
prefix_test = full_test[:, [0, 1]]
# operational settings and raw sensor data
inputs_data = full_data[:, 2:]
inputs_test = full_test[:, 2:]
# to avoid devide zero
eps = 1e-12
# For those who want to try standardiztion:
# mu = np.mean(inputs, axis=0)
# sigma = np.std(inputs, axis=0)
# standard = (inputs - mu) / (sigma + eps)
min = np.min(inputs_data, axis=0)
max = np.max(inputs_data, axis=0)
normed_data = (inputs_data - min) / (max - min + eps)
normed_test = (inputs_test - min) / (max - min + eps)
output_data = np.concatenate((prefix_data, normed_data), axis=1)
output_test = np.concatenate((prefix_test, normed_test), axis=1)
np.savetxt('./datasets/CMAPSSData/train_FD004_normed.txt', output_data, fmt='%f')
np.savetxt('./datasets/CMAPSSData/test_FD004_normed.txt', output_test, fmt='%f')