Skip to main content
. 2019 Feb 23;19(4):947. doi: 10.3390/s19040947
Algorithm 1. Data Pre-process
Input: A time-series matrix d, sliding window size l, sliding window step s
Output: A matrix of final train samples, A matrix of final test samples
1. result = []
2. Initialize the flag number start = 0
3. while start < len(d)
4.  if start + l < len(d)
5.   temp = d.iloc[start:start+l, :]            //data segmentation
6.   reshaped_temp = reshape(temp, [1, l×d.shape [1]]) //data reshaping
7.   result.append(reshaped_temp)
8.    start = start +s
9.  end if
10. end while
11. X_train, X_test = train_test_split(test_size = 0.3)
12. //data standardization
13. for col in X_train.cols
14.  col_max = max(X_train.iloc[:, col])
15.  col_min = min(X_train.iloc[:, col])
16.  X_train.iloc[:, col] = (X_train.iloc[:, col] – col_min)/(col_max – col_min)
17.  X_test.iloc[:, col] = (X_test.iloc[:, col] – col_min)/(col_max – col_min)
18. end for
19. return X_train, X_test