Why concat training and testing data for RNN/ LSTM for stock prediction?

Viewed 76

I've been following this tutorial to pre-process the data for the LSTM model

https://www.kdnuggets.com/2018/11/keras-long-short-term-memory-lstm-model-predict-stock-prices.html

and looking pre-processing the testing data, why do they concat the training and testing data? Would this not cause data leakage?

Here is the code

dataset_total = pd.concat((dataset_train['Open'], dataset_test['Open']), axis = 0)
inputs = dataset_total[len(dataset_total) - len(dataset_test) - 60:].values
inputs = inputs.reshape(-1,1)
inputs = sc.transform(inputs)
X_test = []
for i in range(60, 76):
    X_test.append(inputs[i-60:i, 0])
X_test = np.array(X_test)
X_test = np.reshape(X_test, (X_test.shape[0], X_test.shape[1], 1))
predicted_stock_price = regressor.predict(X_test)
predicted_stock_price = sc.inverse_transform(predicted_stock_price)

And if I was to pre-process validation data would I do the same and concat the training and validation data?

0 Answers
Related