LSTM-RF Stock Prediction Algorithm via Short-Term Directional Probability-Based Model Selection
Abstract
1. Introduction
2. Materials and Methods
2.1. Dataset Preparation
2.2. LSTM Network
2.3. Random Forest
2.4. Proposed LSTM-RF Algorithm
3. Results
3.1. Simulation Environment
3.2. Selection of LSTM Activation Function and Number of Iterations
3.3. Comparison of Accuracy of Four Basic Prediction Models
3.4. Comparison with Other Hybrid Models
4. Discussion
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Shah, D.; Isah, H.; Zulkernine, F. Stock Market Analysis: A Review and Taxonomy of Prediction Techniques. Int. J. Financ. Stud. 2019, 7, 26. [Google Scholar] [CrossRef]
- Soni, P.; Tewari, Y.; Krishnan, D. Machine Learning Approaches in Stock Price Prediction: A Systematic Review. J. Phys. Conf. Ser. 2022, 2161, 012065. [Google Scholar] [CrossRef]
- Madhusudan, D.M. Stock Closing Price Prediction Using Machine Learning SVM Model. Int. J. Res. Appl. Sci. Eng. Technol. 2020, 8, 379–383. [Google Scholar] [CrossRef]
- Emioma, C.C.; Edeki, S.O. Stock Price Prediction Using Machine Learning on Least-Squares Linear Regression Basis. J. Phys. Conf. Ser. 2021, 1734, 012058. [Google Scholar] [CrossRef]
- Sadorsky, P. A Random Forests Approach to Predicting Clean Energy Stock Prices. J. Risk Financ. Manag. 2021, 14, 48. [Google Scholar] [CrossRef]
- Omar, A.B.; Huang, S.; Salameh, A.A.; Khurram, H.; Fareed, M. Stock Market Forecasting Using the Random Forest and Deep Neural Network Models Before and During the COVID-19 Period. Front. Environ. Sci. 2022, 10, 917047. [Google Scholar] [CrossRef]
- Ghosh, P.; Neufeld, A.; Sahoo, J.K. Forecasting Directional Movements of Stock Prices for Intraday Trading Using LSTM and Random Forests. Financ. Res. Lett. 2022, 46, 102280. [Google Scholar] [CrossRef]
- Reddy, M.C.K.; Praneeth, M.; Reddy, K.P.; Reddy, A.S. Stock market trend prediction using K-nearest neighbor (KNN) algorithm. Int. J. Innov. Eng. Manag. Res. 2021, 13, 1–8. [Google Scholar]
- Ahmad, B.; Zakria, M. Comparative Study of Box-Jenkins ARIMA and KNN Algorithm for Stock Price Prediction in Pakistan. J. Soc. Sci. Humanit. 2022, 30, 102–122. [Google Scholar]
- Dash, R.K.; Nguyen, T.N.; Cengiz, K.; Sharma, A. Fine-Tuned Support Vector Regression Model for Stock Predictions. Neural Comput. Appl. 2023, 35, 23295–23309. [Google Scholar] [CrossRef]
- Liu, G.; Ma, W. A Quantum Artificial Neural Network for Stock Closing Price Prediction. Inf. Sci. 2022, 598, 75–85. [Google Scholar] [CrossRef]
- Mehtab, S.; Sen, J. Stock Price Prediction Using Convolutional Neural Networks on a Multivariate Time Series. arXiv 2021, arXiv:1912.07700. [Google Scholar]
- Ghosh, A.; Bose, S.; Maji, G.; Debnath, N.; Sen, S. Stock Price Prediction Using LSTM on Indian Share Market. In Proceedings of the 32nd International Conference on Computer Applications in Industry and Engineering, San Diego, CA, USA, 30 September–2 October 2019; pp. 101–190. [Google Scholar]
- Ding, G.; Qin, L. Study on the Prediction of Stock Price Based on the Associated Network Model of LSTM. Int. J. Mach. Learn. Cybern. 2020, 11, 1307–1317. [Google Scholar] [CrossRef]
- Jin, Z.; Yang, Y.; Liu, Y. Stock Closing Price Prediction Based on Sentiment Analysis and LSTM. Neural Comput. Appl. 2020, 32, 9713–9729. [Google Scholar] [CrossRef]
- Ge, Q. Enhancing Stock Market Forecasting: A Hybrid Model for Accurate Prediction of S&P 500 and CSI 300 Future Prices. Expert Syst. Appl. 2025, 260, 125380. [Google Scholar] [CrossRef]
- Tian, B.; Yan, T.; Yin, H. Forecasting the Volatility of CSI 300 Index with a Hybrid Model of LSTM and Multiple GARCH Models. Comput. Econ. 2025, 66, 1969–1999. [Google Scholar] [CrossRef]
- Gupta, U.; Bhattacharjee, V.; Bishnu, P.S. StockNet—GRU Based Stock Index Prediction. Expert Syst. Appl. 2022, 207, 117986. [Google Scholar] [CrossRef]
- Fang, W.; Zhang, S.; Xu, C. Improving Prediction Efficiency of Chinese Stock Index Futures Intraday Price by VIX-Lasso-GRU Model. Expert Syst. Appl. 2024, 238, 121968. [Google Scholar] [CrossRef]
- Chen, C.; Xue, L.; Xing, W. Research on Improved GRU-Based Stock Price Prediction Method. Appl. Sci. 2023, 13, 8813. [Google Scholar] [CrossRef]
- Chen, Y.-C.; Huang, W.-C. Constructing a Stock-Price Forecast CNN Model with Gold and Crude Oil Indicators. Appl. Soft Comput. 2021, 112, 107760. [Google Scholar] [CrossRef]
- Zhu, C.; Yahya Dawod, A.; Xi, Y.; Chen, G. A Portfolio Optimization Model for Return Trend Rate and Risk Trend Rate Based on Machine Learning. IAES Int. J. Artif. Intell. (IJ-AI) 2025, 14, 933. [Google Scholar] [CrossRef]
- Qi, C.; Ren, J.; Su, J. GRU Neural Network Based on CEEMDAN–Wavelet for Stock Price Prediction. Appl. Sci. 2023, 13, 7104. [Google Scholar] [CrossRef]
- Kumar, I.; Dogra, K.; Utreja, C.; Yadav, P. A Comparative Study of Supervised Machine Learning Algorithms for Stock Market Trend Prediction. In Proceedings of the 2018 Second International Conference on Inventive Communication and Computational Technologies (ICICCT), Coimbatore, India, 20–21 April 2018; IEEE: New York, NY, USA, 2018; pp. 1003–1007. [Google Scholar]
- Kurani, A.; Doshi, P.; Vakharia, A.; Shah, M. A Comprehensive Comparative Study of Artificial Neural Network (ANN) and Support Vector Machines (SVM) on Stock Forecasting. Ann. Data. Sci. 2023, 10, 183–208. [Google Scholar] [CrossRef]
- Livieris, I.E.; Pintelas, E.; Pintelas, P. A CNN–LSTM Model for Gold Price Time-Series Forecasting. Neural Comput. Appl. 2020, 32, 17351–17360. [Google Scholar] [CrossRef]
- Wu, J.M.-T.; Li, Z.; Herencsar, N.; Vo, B.; Lin, J.C.-W. A Graph-Based CNN-LSTM Stock Price Prediction Algorithm with Leading Indicators. Multimed. Syst. 2023, 29, 1751–1770. [Google Scholar] [CrossRef]
- Varadharajan, V.; Smith, N.; Kalla, D.; Kumar, G.R.; Samaah, F.; Polimetla, K. Stock Closing Price and Trend Prediction with LSTM-RNN. J. Artif. Intell. Big Data 2024, 4, 1–13. [Google Scholar] [CrossRef]
- Ma, Y.; Wang, W.; Ma, Q. A Novel Prediction Based Portfolio Optimization Model Using Deep Learning. Comput. Ind. Eng. 2023, 177, 109023. [Google Scholar] [CrossRef]
- Farhadi, A.; Zamanifar, A.; Alipour, A.; Taheri, A.; Asadolahi, M. A Hybrid LSTM-GRU Model for Stock Price Prediction. IEEE Access 2025, 13, 117594–117618. [Google Scholar] [CrossRef]
- Tripathy, N.; Parida, S.; Nayak, S.K. Forecasting Stock Market Indices Using Gated Recurrent Unit (GRU) Based Ensemble Models: LSTM-GRU. Int. J. Comput. Commun. Technol. 2023, 9, 85–90. [Google Scholar] [CrossRef]
- Lu, W.; Li, J.; Li, Y.; Sun, A.; Wang, J. A CNN-LSTM-Based Model to Forecast Stock Prices. Complexity 2020, 2020, 6622927. [Google Scholar] [CrossRef]
- Sahoo, J. Learning to Trade: Deep Neural Networks for Robust Stock Market Price Forecasting. Int. J. Eng. Inf. Manag. 2026, 2, 83–107. [Google Scholar] [CrossRef]
- Muhammad, T.; Aftab, A.B.; Ibrahim, M.; Ahsan, M.M.; Muhu, M.M.; Khan, S.I.; Alam, M.S. Transformer-based deep learning model for stock price prediction: A case study on Bangladesh stock market. Int. J. Comput. Intell. Appl. 2023, 22, 2350013. [Google Scholar] [CrossRef]
- Ridhawi, M.A.; Ali, M.H.; Al Osman, H. Stock Market Prediction Using Node Transformer Architecture Integrated with BERT Sentiment Analysis. IEEE Access 2026, 14, 72613–72631. [Google Scholar] [CrossRef]
- Li, S.; Xu, S. Enhancing Stock Price Prediction Using GANs and Transformer-Based Attention Mechanisms. Empir. Econ. 2025, 68, 373–403. [Google Scholar] [CrossRef]











| Study | Dataset/Market | Feature Selection Strategy | Prediction Model | Evaluation Metrics | Main Contribution | Key Limitations |
|---|---|---|---|---|---|---|
| [5] | five US’s clean energy ETFs | Stock daily trading data | RF | MD accuracy, MD Gini | RFs and tree bagging show much better | There is no deep learning involved. |
| [21] | The S&P 500 (GSPC) | Closing price, SMA, EMA, ROC, MACD, Fast %K, Slow %D, Upper band, Lower band, %B, oil price, oil volatility index, gold price, gold volatility index | CNN | Accuracy, Precision, Recall, F1 score | Conducted a classified discussion experiment on the input indicators | The data is rather limited. |
| [22] | the Shanghai and Shenzhen Stock Exchange | Stock daily trading data | LSTM | HR, AR, SR, MD | The introduction of the trend rate indicator has improved the prediction accuracy. | The data is rather limited. |
| [23] | S&P500 and CSI 300 stock indices | opening price, closing price, highest price, and lowest price | GRU | MSE, MAE | the wavelet threshold method is specifically used to denoise high-frequency noise | only have four-dimensional features |
| [32] | the Shanghai Composite Index | opening price, highest price, lowest price, closing price, volume, turnover, ups and downs, and change | CNN-LSTM | MAE, RMSE, R2 | Use CNN to extract the features of the input data | The data is rather limited. |
| [28] | the Amazon Inc. stock | Stock daily trading data | LSTM-RNN | RMSE, MAE, MAPE | A LSTM-RNN model was constructed. | The data is rather limited. |
| [30] | Eight stocks of Iranian listed companies | 42 indicators | LSTM-GRU | MSE, MAE, MAPE | A LSTM-GRU model was constructed. | The data is rather limited. |
| [29] | the CSI 100 component stocks | past 60 days’ logarithmic daily returns | AE + LSTM + OMEG | HR, HR+, HR−, MSE, MAE | An AE + LSTM + OMEGA model was constructed. | TAE feature processing is prone to introducing noise. |
| Proposed Study | 9 listed stocks of the Shanghai and Shenzhen Stock Exchange | opening price, closing value, minimum price, maximum price, trading volume, trading amount, amplitude, increase/decrease amount, increase/decrease percentage, and turnover rate | LSTM-RF | MAPE, HR, HR+, HR−, MSE | Improved directional prediction performance | The data is rather limited. |
| Parameters | Values |
|---|---|
| Hidden layers | 1, 2, 3 |
| Number of nodes in each layer | 10, 20, 32, 64 |
| Learning rate | 0.001, 0.01, 0.1 |
| Number of iterations | 240 |
| Dropout rate | 0.1, 0.2, …, 0.5 |
| Loss function | MAPE, MSE |
| Active function | tanh |
| Number of days of LSTM memory | 1, 2, 3, …, 10 |
| Corresponding Index | Stock Code | Start Time of Statistics | End Time of Statistics | Total Trading Days | Trading Day of 2023 |
|---|---|---|---|---|---|
| Shanghai Composite Index | 600837 | 1 January 2018 | 31 December 2023 | 1457 days | 242 days |
| 601995 | 2 November 2020 | 31 December 2023 | 771 days | 242 days | |
| 603881 | 1 January 2018 | 31 December 2023 | 1457 days | 242 days | |
| Shenzhen Composite Index | 000333 | 1 January 2018 | 31 December 2023 | 1417 days | 242 days |
| 002033 | 1 January 2018 | 31 December 2023 | 1411 days | 242 days | |
| 002343 | 1 January 2018 | 31 December 2023 | 1452 days | 242 days | |
| ChiNext Market | 300059 | 1 January 2018 | 31 December 2023 | 1457 days | 242 days |
| 300083 | 1 January 2018 | 31 December 2023 | 1437 days | 242 days | |
| 600977 | 1 January 2018 | 31 December 2023 | 1457 days | 242 days |
| Index | Model | Prediction Statistics (%) | Average (%) | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 000333 | 002033 | 002343 | 300059 | 300083 | 600977 | 600837 | 601995 | 603881 | |||
| HR | LSTM-RF | 53.94 | 50.21 | 56.43 | 56.43 | 56.02 | 56.43 | 52.28 | 55.19 | 54.77 | 54.63 |
| LSTM | 49.79 | 51.45 | 49.38 | 57.26 | 54.77 | 52.28 | 53.94 | 56.43 | 54.36 | 53.30 | |
| RF | 56.85 | 48.96 | 59.34 | 52.70 | 49.38 | 59.34 | 47.72 | 50.21 | 54.77 | 53.25 | |
| GRU | 51.45 | 51.04 | 50.21 | 48.55 | 48.13 | 45.64 | 50.62 | 54.77 | 51.87 | 50.25 | |
| CNN | 57.26 | 50.62 | 49.79 | 52.28 | 51.87 | 44.40 | 49.79 | 46.06 | 51.87 | 50.44 | |
| HR− | LSTM-RF | 53.33 | 48.57 | 57.59 | 61.83 | 55.85 | 56.99 | 50.00 | 56.77 | 54.97 | 55.10 |
| LSTM | 47.11 | 20.51 | 44.19 | 60.29 | 77.34 | 54.35 | 53.04 | 68.99 | 65.32 | 54.57 | |
| RF | 80.17 | 58.12 | 82.17 | 36.76 | 67.19 | 58.73 | 71.30 | 55.04 | 61.29 | 63.42 | |
| GRU | 83.47 | 71.79 | 48.06 | 52.21 | 50.00 | 51.59 | 45.22 | 75.19 | 61.29 | 59.87 | |
| CNN | 69.85 | 36.21 | 50.43 | 62.02 | 54.96 | 80.77 | 54.20 | 64.84 | 62.90 | 59.58 | |
| HR+ | LSTM-RF | 54.95 | 51.47 | 54.22 | 50.00 | 56.60 | 54.55 | 55.14 | 52.33 | 54.44 | 53.74 |
| LSTM | 52.50 | 80.65 | 55.36 | 53.33 | 29.20 | 45.61 | 54.76 | 41.96 | 42.74 | 50.68 | |
| RF | 33.33 | 40.32 | 33.04 | 73.33 | 29.20 | 61.54 | 26.19 | 44.64 | 47.86 | 43.27 | |
| GRU | 19.17 | 31.45 | 52.68 | 43.81 | 46.02 | 39.13 | 55.56 | 31.25 | 41.88 | 40.10 | |
| CNN | 40.95 | 64.00 | 49.19 | 41.07 | 48.18 | 16.79 | 44.55 | 24.78 | 40.17 | 41.08 | |
| MAPE | LSTM-RF | 1.44 | 4.14 | 3.10 | 2.08 | 2.47 | 2.13 | 1.38 | 2.16 | 2.79 | 2.41 |
| LSTM | 2.06 | 7.97 | 4.61 | 3.11 | 3.18 | 2.83 | 2.48 | 3.68 | 3.82 | 3.75 | |
| RF | 1.36 | 2.27 | 2.66 | 1.99 | 2.40 | 1.95 | 0.94 | 1.52 | 2.46 | 1.95 | |
| GRU | 2.32 | 3.39 | 4.58 | 2.36 | 3.51 | 3.40 | 1.78 | 2.69 | 3.25 | 3.03 | |
| CNN | 3.22 | 7.11 | 5.56 | 6.38 | 3.80 | 5.23 | 6.22 | 6.44 | 5.14 | 5.46 | |
| Index | Model | Prediction Statistics (%) | Average (%) | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 000333 | 002033 | 002343 | 300059 | 300083 | 600977 | 600837 | 601995 | 603881 | |||
| HR | LSTM-RF | 53.94 | 50.21 | 56.43 | 56.43 | 56.02 | 56.43 | 52.28 | 55.19 | 54.77 | 54.63 |
| CNN-LSTM | 51.3 | 35.24 | 44.46 | 53.53 | 55.43 | 53.35 | 48.04 | 54.38 | 53.86 | 49.95 | |
| LSTM-RNN | 49.52 | 34.85 | 45.43 | 55.58 | 60.31 | 52.89 | 50.43 | 58.31 | 56.54 | 51.54 | |
| LSTM-GRU | 55.6 | 46.42 | 45.91 | 52.62 | 54.76 | 48.66 | 48.41 | 61.54 | 55.39 | 52.14 | |
| AE + LSTM | 48.13 | 50.62 | 44.81 | 52.70 | 47.72 | 43.15 | 51.04 | 57.26 | 51.87 | 49.70 | |
| HR− | LSTM-RF | 53.33 | 48.57 | 57.59 | 61.83 | 55.85 | 56.99 | 50.00 | 56.77 | 54.97 | 55.10 |
| CNN-LSTM | 51.13 | 21.31 | 41.16 | 54.1 | 59 | 60.61 | 46.17 | 59.36 | 56.76 | 49.95 | |
| LSTM-RNN | 49.23 | 20.87 | 43.29 | 57.06 | 68.18 | 57.39 | 49.57 | 64.69 | 61.25 | 52.39 | |
| LSTM-GRU | 62.41 | 43.27 | 43.65 | 54.47 | 60.19 | 50.29 | 46.35 | 69.41 | 59.59 | 54.4 | |
| AE + LSTM | 52.89 | 41.03 | 40.31 | 49.26 | 38.28 | 32.82 | 40.87 | 68.99 | 42.74 | 45.24 | |
| HR+ | LSTM-RF | 54.95 | 51.47 | 54.22 | 50.00 | 56.60 | 54.55 | 55.14 | 52.33 | 54.44 | 53.74 |
| CNN-LSTM | 52.87 | 50.38 | 48.96 | 54.12 | 52.87 | 47.69 | 51.11 | 50.59 | 52.36 | 51.22 | |
| LSTM-RNN | 51.18 | 50.43 | 48.97 | 55.5 | 53.63 | 49.8 | 52.49 | 53.32 | 53.42 | 52.08 | |
| LSTM-GRU | 50.59 | 51.17 | 49.77 | 52.78 | 51.32 | 48.83 | 52.25 | 55.67 | 52.99 | 51.71 | |
| AE + LSTM | 43.33 | 59.68 | 50.00 | 57.14 | 58.41 | 55.45 | 60.32 | 43.75 | 61.54 | 54.40 | |
| MAPE | LSTM-RF | 1.44 | 4.14 | 3.10 | 2.08 | 2.47 | 2.13 | 1.38 | 2.16 | 2.79 | 2.41 |
| CNN-LSTM | 2.41 | 8.22 | 4.86 | 3.43 | 3.43 | 3.38 | 2.73 | 3.93 | 4.17 | 4.06 | |
| LSTM-RNN | 1.96 | 2.79 | 3.06 | 2.49 | 3 | 2.35 | 1.34 | 2.12 | 2.96 | 2.45 | |
| LSTM-GRU | 2.44 | 3.49 | 4.78 | 2.36 | 3.51 | 3.5 | 1.78 | 2.69 | 3.38 | 3.1 | |
| AE + LSTM | 2.42 | 7.93 | 5.44 | 3.67 | 4.07 | 4.10 | 2.90 | 3.60 | 4.28 | 4.27 | |
| Model | p-Values (Compared with the LSTM-RF Model) |
|---|---|
| LSTM | DM = 3.1670, p-value1 = 0.001540; p-value2 = 0.0455 |
| RF | DM = 3.2130, p-value1 = 0.001314; p-value2 = 0.0462 |
| GRU | DM = 4.1670, p-value1 = 0.000031; p-value2 = 0.0344 |
| CNN | DM = 4.0481, p-value1 = 0.000052; p-value2 = 0.0381 |
| CNN-LSTM | DM = 4.9481, p-value1 = 0.000001; p-value2 = 0.0189 |
| LSTM-RNN | DM = 3.8820, p-value1 = 0.000104; p-value2 = 0.0422 |
| LSTM-GRU | DM = 3.5432, p-value1 = 0.000395; p-value2 = 0.0428 |
| AE + LSTM | DM = 5.0131, p-value1 = 0.000001; p-value2 = 0.0171 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Zhu, C.; Dawod, A.Y.; Yu, X.; Zhou, Q. LSTM-RF Stock Prediction Algorithm via Short-Term Directional Probability-Based Model Selection. Information 2026, 17, 548. https://doi.org/10.3390/info17060548
Zhu C, Dawod AY, Yu X, Zhou Q. LSTM-RF Stock Prediction Algorithm via Short-Term Directional Probability-Based Model Selection. Information. 2026; 17(6):548. https://doi.org/10.3390/info17060548
Chicago/Turabian StyleZhu, Chunman, Ahmad Yahya Dawod, Xi Yu, and Qingwei Zhou. 2026. "LSTM-RF Stock Prediction Algorithm via Short-Term Directional Probability-Based Model Selection" Information 17, no. 6: 548. https://doi.org/10.3390/info17060548
APA StyleZhu, C., Dawod, A. Y., Yu, X., & Zhou, Q. (2026). LSTM-RF Stock Prediction Algorithm via Short-Term Directional Probability-Based Model Selection. Information, 17(6), 548. https://doi.org/10.3390/info17060548

