
Artificial Intelligence in Stock Price Forecasting: GRU, LSTM and XGBoost Competition for Apple's Future
Chapter from the book:
Türkoğlu,
D.
(ed.)
2025.
Financial Markets and Algorithms: New Generation Investment Strategies.
Synopsis
Stock price predictions are of great importance for investors and financial analysts. The complex and dynamic nature of financial markets makes accurate predictions both challenging and more valuable. Accurate predictions allow investors to minimize risks, manage their portfolios more effectively, and make strategic decisions, providing them with a competitive advantage in the market. Especially during periods of high volatility, accurate predictions can prevent investors from experiencing significant losses and help them achieve more stable gains. Today, advancing technology and data analysis methods play a crucial role in stock price predictions. In this study, three different models were used to predict Apple's stock prices: GRU (Gated Recurrent Unit), LSTM (Long Short-Term Memory), and XGBoost (Extreme Gradient Boosting). Each model is specially designed to analyze time series data and predict future price movements. The study was conducted in a Jupyter Notebook environment using the Python programming language. Hyperparameter adjustments were made to maximize the performance of the models, and optimal parameters were determined for each model. During this process, the accuracy rates, error rates, and overall performance of the models were compared. As a result of the analyses, it was observed that the LSTM model provided more accurate and efficient predictions compared to the GRU and XGBoost models. The superior performance of the LSTM model can be attributed to its ability to capture long-term dependencies. LSTM can make more accurate predictions, especially in time series data, by retaining important historical information in its memory. This feature provides a significant advantage in volatile and complex datasets such as financial data. Although the GRU model has a similar structure, it remained limited in capturing long-term dependencies compared to LSTM. XGBoost, despite being a powerful machine learning algorithm, was not as effective as deep learning models in capturing the sequence in time series data. In conclusion, the findings obtained in this study demonstrate the potential of the LSTM model in stock price predictions. The LSTM model can be effectively used not only for Apple stock but also for financial data analysis in general. These results provide an important contribution to more accurate analysis of financial markets and establishing investment strategies on more solid foundations. In future studies, a broader perspective can be obtained by examining the performance of similar models on stocks of different companies. Additionally, prediction accuracies can be further improved by using model combinations and hybrid approaches.