Comparative Analysis of Machine Learning Algorithms for Stock Price Prediction

DOI: https://doi.org/jobasr

Maikatsina B. I.

Chaku E. S.

Umar M. I.

Abstract
Stock price prediction plays a crucial role in financial research and investment strategy, as market volatility often makes investor decision-making uncertain and risky. This study aims to investigate the application of machine learning techniques for stock price prediction, focusing on comparing the effectiveness of four algorithms: Long Short-Term Memory (LSTM) networks, Support Vector Machines (SVM), Random Forests, and Linear Regression. The study examines how advanced feature selection, data preprocessing, and the incorporation of sentiment analysis can enhance predictive accuracy. Historical stock data were collected from major markets such as the New York Stock Exchange (NYSE) and the Nigerian Stock Exchange (NSE) via Yahoo Finance and Alpha Vantage, while sentiment data were obtained from Twitter and financial news platforms including Reuters and Bloomberg. The models were trained and evaluated using statistical metrics such as Mean Squared Error (MSE), Mean Absolute Error (MAE), and R-squared (R²). The results show that LSTM consistently outperformed all other models, achieving the lowest MSE (0.0023), MAE (0.036), and the highest R² (0.923), demonstrating its ability to capture temporal dependencies and nonlinear patterns in stock price data. Random Forest ranked second, effectively modeling nonlinear relationships, while SVM showed moderate performance. Linear Regression, serving as a baseline, recorded the least predictive accuracy due to its linear assumptions. The integration of sentiment analysis and technical indicators significantly improved model performance, emphasizing the advantage of hybrid feature sets. These findings imply that investors, analysts, and financial institutions can significantly improve the accuracy of their forecasts and the efficiency of their investment strategies by adopting deep learning models such as LSTM for stock price prediction.
References
PDF