The LSTM model is a type of artificial neural network and stands for Long Short-Term Memory network.
It’s an improvement over RNN (Recurrent Neural Network), which often struggles with long-term dependencies in sequential data and are prone to the vanishing gradient problem.
The LSTM model addresses this issue with the integration of a memory cell with gated connections that can selectively remember or forget information from previous time steps.
This allows the model to capture important long-term patterns or information and make predictions for future time steps.
As a result, this makes LSTM suitable for modeling time-dependent data with long-term dependencies and forecasting time-series data like stock prices.
This project focuses on predicting the stock prices of
Apple Inc. (AAPL)
, but an LSTM model should work on any stocks by simply switching up the input data.
The historical AAPL stock prices going all the way back to 2000 were extracted from
Yahoo Finance
and used to train the model.
The model was built using the Pytorch package in Python.
Two different LSTM models were built and evaluated - one with a single LSTM layer, and another with two LSTM layers.
The intention was to see how model complexity affects the accuracy of the prediction.
Based on the findings from the training stage, it seems that a simpler model like the single-layer LSTM is effective for modeling and predicting time-dependent data such as stock prices. For this case, the single-layer LSTM model outperformed the multi-layer LSTM model and produced predictions that were closest to the actual stock price. Overall, the LSTM model can be an effective tool for forecasting stock prices or other time-dependent data after careful consideration of model architecture and hyperparameters.
The model could be trained with fine-tuned hyperparameters using all historical data from 2000 until today. Once trained, the model can then be used to predict only the stock price for the following day.