|
Algorithm 1. Data Pre-process |
|
Input: A time-series matrix , sliding window size , sliding window step
|
|
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() |
| 4. if start + < len() |
| 5. temp = .iloc[start:start+, :] //data segmentation |
| 6. reshaped_temp = reshape(temp, [1, .shape [1]]) //data reshaping |
| 7. result.append(reshaped_temp) |
| 8. start = start +
|
| 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 |