Using a neural network – LSTM
We explained in detail how LSTM works in Chapter 8. Briefly, LSTM serves as a specialized form of recurrent neural network (RNN) designed to detect patterns in data sequences. Its distinct feature lies in its capacity to preserve information over extended periods compared to conventional RNNs. LSTM overcomes this short-term memory problem by selectively retaining relevant information.
Preprocessing
We will treat the problem as a supervised learning (SL) task. For that purpose, we will modify the training set as follows:
- Scale the dataset using the
MinMaxScaler()
. - Iterate through the scaled dataset and retrieve the 60 days previous to the current price (
y_train)
and convert them into features for each price. The result will be a training dataset with 60 price columns asx_train
features for each BTC price (y_train
). In summary, for each data point that the model learns, it refers to the previous 60 days inx_train
:
...