Stock Price Forecasting Using LSTM with Cross-Validation
DOI:
https://doi.org/10.26740/vubeta.v3i1.45130Keywords:
Stock Price Forecasting, LSTM (Long Short-Term Memory), Cross-Validation, Deep Learning, Sequence ForecastingAbstract
Stock price prediction remains challenging due to the market’s nonlinear, volatile nature, influenced by diverse economic and behavioral factors. Traditional models often suffer from overfitting and limited generalizability. This study addresses these limitations from prior research by other researchers for integrating Long Short-Term Memory (LSTM) with k-Fold Cross-Validation to improve prediction robustness. The proposed framework systematically evaluates model performance across varying market conditions. This methodological contribution enhances forecasting accuracy and stability, offering a more reliable approach to complex financial time series prediction. This study employs LSTM with one to two layers of 64–128 units, trained using Adam and dropout regularization, to capture long-term dependencies in stock price data. The workflow integrates feature selection, Min-Max scaling, and k-Fold Cross-Validation for robust evaluation. Model performance is assessed using RMSE, with reconfiguration applied to address underfitting or overfitting. The proposed model demonstrated substantial performance gains, achieving an average RMSE improvement of approximately 78.40% across all tested stocks compared to prior research. These enhancements are attributed to optimal hyperparameter tuning, consistent use of the Adam optimizer, and the implementation of k-Fold Cross-Validation, which reduced overfitting and provided more stable evaluations. Furthermore, findings revealed that simpler feature sets, such as using only closing prices, can outperform multiple technical indicators when normalization is inadequate, underscoring the importance of robust preprocessing and validation strategies. This study concludes that integrating LSTM with k-Fold Cross-Validation and optimized hyperparameters significantly improves stock price prediction accuracy.
References
[1] H. Bhandari, B. Rimal, N. Pokhrel, R. Rimal, K. Dahal, & R. Khatri, "Predicting Stock Market Index using LSTM", Machine Learning with Applications, vol. 9, pp. 100320, 2022. https://doi.org/10.1016/j.mlwa.2022.100320
[2] J. Shah, D. Vaidya, & M. Shah, "A Comprehensive Review on Multiple Hybrid Deep Learning Approaches for Stock Prediction", Intelligent Systems with Applications, vol. 16, pp. 200111, 2022. https://doi.org/10.1016/j.iswa.2022.200111
[3] F. Furizal, A. Ritonga, A. Ma’arif, & I. Suwarno "Stock Price Forecasting with Multivariate Time Series Long Short-Term Memory: A Deep Learning Approach", Journal of Robotics and Control, vol. 5, no. 5, pp. 1322-1335, 2024. https://doi.org/10.18196/jrc.v5i5.22460
[4] R. Zhang, "LSTM-based Stock Prediction Modeling and Analysis", Advances in Economics, Business and Management Research, 2022. https://doi.org/10.2991/aebmr.k.220307.414
[5] H. Qian, "Stock Predicting based on LSTM and ARIMA", Advances in Economics, Business and Management Research, pp. 485-490, 2022. https://doi.org/10.2991/978-94-6463-036-7_72
[6] C. Jiang, Y. Tsai, Z. Shao, S. Lee, C. Hsueh, & K. Huang, "Hybrid Crow Search Algorithm–LSTM System for Enhanced Stock Price Forecasting", Applied Sciences, vol. 14, no. 23, pp. 11380, 2024. https://doi.org/10.3390/app142311380
[7] K. Liagkouras and K. Metaxiotis, "A Hybrid Long Short-Term Memory with a Sentiment Analysis System for Stock Market Forecasting", Electronics, vol. 14, no. 14, pp. 2753, 2025. https://doi.org/10.3390/electronics14142753
[8] M. Ali, D. Khan, H. Alshanbari, & A. El-Bagoury, "Prediction of Complex Stock Market Data Using an Improved Hybrid EMD-LSTM Model", Applied Sciences, vol. 13, no. 3, pp. 1429, 2023. https://doi.org/10.3390/app13031429
[9] P. Ye, H. Zhang, & X. Zhou, "CNN-CBAM-LSTM: Enhancing Stock Return Prediction Through Long and Short Information Mining in Stock Prediction", Mathematics, vol. 12, no. 23, pp. 3738, 2024. https://doi.org/10.3390/math12233738
[10] F. Fozap, "Hybrid Machine Learning Models for Long-Term Stock Market Forecasting: Integrating Technical Indicators", Journal of Risk and Financial Management, vol. 18, no. 4, pp. 201, 2025. https://doi.org/10.3390/jrfm18040201
[11] Q. Li, N. Kamaruddin, S. Yuhaniz, & H. Al-Jaifi, "Forecasting Stock Prices Changes using Long-Short Term Memory Neural Network with Symbolic Genetic Programming", Scientific Reports, vol. 14, no. 1, 2024. https://doi.org/10.1038/s41598-023-50783-0
[12] G. Sonkavde, D. Dharrao, A. Bongale, S. Deokate, D. Doreswamy, & S. Bhat, "Forecasting Stock Market Prices Using Machine Learning and Deep Learning Models: A Systematic Review, Performance Analysis and Discussion of Implications", International Journal of Financial Studies, vol. 11, no. 3, pp. 94, 2023. https://doi.org/10.3390/ijfs11030094
[13] A. Kid, M. Ahmed, A. Alkali, J. Usman, & A. Hashim, "Real-Time Energy Demand Forecasting and Adaptive Demand Response Optimization for IoT-Enabled Smart Grids", Vokasi Unesa Bulletin of Engineering, Technology and Applied Science, vol. 2, no. 2, pp. 366-375, 2025. https://doi.org/10.26740/vubeta.v2i2.36818
[14] B. Gülmez, "A Hybrid Approach for Stock Market Price Forecasting Using Long Short-Term Memory and Seahorse Optimization Algorithm", Annals of Data Science, 2025. https://doi.org/10.1007/s40745-025-00609-9
[15] E. Radfar, "Stock Market Trend Prediction using Deep Neural Network via Chart Analysis: A Practical Method or A Myth?", Humanities and Social Sciences Communications, vol. 12, no. 1, 2025. https://doi.org/10.1057/s41599-025-04761-8
[16] V. Varadharajan, N. Smith, D. Kalla, G. Kumar, F. Samaah, & K. Polimetla, "Stock Closing Price and Trend Prediction with LSTM-RNN", Journal of Artificial Intelligence and Big Data, vol. 4, no. 1, pp. 1-13, 2024. https://doi.org/10.31586/jaibd.2024.877
[17] V. Chang, Q. Xu, A. Chidozie, & H. Wang, "Predicting Economic Trends and Stock Market Prices with Deep Learning and Advanced Machine Learning Techniques", Electronics, vol. 13, no. 17, pp. 3396, 2024. https://doi.org/10.3390/electronics13173396
[18] I. Agung, T. Arifin, E. Junianto, M. Rabbani, & A. Mayangsari, "Stock’s Selection and Trend Prediction using Technical Analysis and Artificial Neural Network", International Journal of Advances in Applied Sciences, vol. 14, no. 1, pp. 151, 2025. https://doi.org/10.11591/ijaas.v14.i1.pp151-163
[19] T. Ogundunmade, A. Adepoju, & A. Allam, "Stock Price Forecasting: Machine Learning Models with K-fold and Repeated Cross Validation Approaches", Modern Economy and Management, vol. 1, pp. 1, 2022. https://doi.org/10.53964/mem.2022001
[20] S. Zaheer, N. Anjum, S. Hussain, A. Algarni, J. Iqbal, S. Bourouis et al., "A Multi Parameter Forecasting for Stock Time Series Data Using LSTM and Deep Learning Model", Mathematics, vol. 11, no. 3, pp. 590, 2023. https://doi.org/10.3390/math11030590
[21] X. Kong, Z. Chen, W. Liu, K. Ning, L. Zhang, S. Marier et al., "Deep Learning for Time Series Forecasting: A Survey", International Journal of Machine Learning and Cybernetics, vol. 16, no. 7-8, pp. 5079-5112, 2025. https://doi.org/10.1007/s13042-025-02560-w
[22] D. El-Shahat, A. Tolba, M. Abouhawwash, & M. Abdel‐Basset, "Machine Learning and Deep Learning Models based Grid Search Cross Validation for Short-Term Solar Irradiance Forecasting", Journal of Big Data, vol. 11, no. 1, 2024. https://doi.org/10.1186/s40537-024-00991-w
[23] X. Song, L. Deng, H. Wang, Y. Zhang, Y. He, & W. Cao, "Deep Learning-based Time Series Forecasting", Artificial Intelligence Review, vol. 58, no. 1, 2024. https://doi.org/10.1007/s10462-024-10989-8
[24] M. Krichen and A. Mihoub, "Long Short-Term Memory Networks: A Comprehensive Survey", Ai, vol. 6, no. 9, pp. 215, 2025. https://doi.org/10.3390/ai6090215
[25] I. Malashin, В. Тынченко, A. Gantimurov, V. Nelyub, & А. Бородулин, "Applications of Long Short-Term Memory (LSTM) Networks in Polymeric Sciences: A Review", Polymers, vol. 16, no. 18, pp. 2607, 2024. https://doi.org/10.3390/polym16182607
[26] C. Ubal, G. Di-Giorgi, J. Contreras‐Reyes, & R. Salas, "Predicting the Long-Term Dependencies in Time Series Using Recurrent Artificial Neural Networks", Machine Learning and Knowledge Extraction, vol. 5, no. 4, pp. 1340-1358, 2023. https://doi.org/10.3390/make5040068
[27] V. Naghashi, M. Boukadoum, & A. Diallo, "Should We Reconsider RNNs for Time-Series Forecasting?", Ai, vol. 6, no. 5, pp. 90, 2025. https://doi.org/10.3390/ai6050090
[28] S. Mu, B. Liu, G. Jijian, C. Lien, & N. Nedjah, "Research on Stock Index Prediction Based on the Spatiotemporal Attention BiLSTM Model", Mathematics, vol. 12, no. 18, pp. 2812, 2024. https://doi.org/10.3390/math12182812
[29] S. Shi, F. Li, & W. Li, "A Hybrid Long Short-Term Memory-Graph Convolutional Network Model for Enhanced Stock Return Prediction: Integrating Temporal and Spatial Dependencies", Mathematics, vol. 13, no. 7, pp. 1142, 2025. https://doi.org/10.3390/math13071142
[30] M. Kabir, D. Bhadra, M. Ridoy, & M. Milanova, "LSTM–Transformer-Based Robust Hybrid Deep Learning Model for Financial Time Series Forecasting", Sci, vol. 7, no. 1, pp. 7, 2025. https://doi.org/10.3390/sci7010007
[31] S. Sang and L. Li, "A Novel Variant of LSTM Stock Prediction Method Incorporating Attention Mechanism", Mathematics, vol. 12, no. 7, pp. 945, 2024. https://doi.org/10.3390/math12070945
[32] O. Chamorro-Atalaya, J. Arévalo-Tuesta, D. Balarezo-Mares, A. Pacheco, O. Mendoza-León, M. Silvestre et al., "K-Fold Cross-Validation through Identification of the Opinion Classification Algorithm for the Satisfaction of University Students", International Journal of Online and Biomedical Engineering (iJOE), vol. 19, no. 11, 2023. https://doi.org/10.3991/ijoe.v19i11.39887
[33] T. Leinonen, D. Wong, A. Vasankari, A. Wahab, R. Nadarajah, M. Kaisti et al., "Empirical Investigation of Multi-Source Cross-Validation in Clinical ECG Classification", Computers in Biology and Medicine, vol. 183, pp. 109271, 2024. https://doi.org/10.1016/j.compbiomed.2024.109271
[34] D. Wilimitis and C. Walsh, "Practical Considerations and Applied Examples of Cross-Validation for Model Development and Evaluation in Health Care: Tutorial", Jmir Ai, vol. 2, pp. e49023, 2023. https://doi.org/10.2196/49023
[35] T. Bradshaw, Z. Huemann, J. Hu, & A. Rahmim, "A Guide to Cross-Validation for Artificial Intelligence in Medical Imaging", Radiology: Artificial Intelligence, vol. 5, no. 4, 2023. https://doi.org/10.1148/ryai.220232
[36] J. Allgaier and R. Pryss, "Cross-Validation Visualized: A Narrative Guide to Advanced Methods", Machine Learning and Knowledge Extraction, vol. 6, no. 2, pp. 1378-1388, 2024. https://doi.org/10.3390/make6020065
[37] A. Aziz, M. Yusoff, W. Yaacob, & Z. Mustaffa, "Repeated Time-Series Cross-Validation: A New Method to Improved COVID-19 Forecast Accuracy in Malaysia", MethodsX, vol. 13, pp. 103013, 2024. https://doi.org/10.1016/j.mex.2024.103013
[38] P. Ali, "Investigating the Impact of Min-Max Data Normalization on the Regression Performance of K-Nearest Neighbor with Different Similarity Measurements", Aro-the Scientific Journal of Koya University, vol. 10, no. 1, pp. 85-91, 2022. https://doi.org/10.14500/aro.10955
[39] X. Cao, I. Stojković, & Z. Obradović, "A Robust Data Scaling Algorithm to Improve Classification Accuracies in Biomedical Data", BMC Bioinformatics, vol. 17, no. 1, 2016. https://doi.org/10.1186/s12859-016-1236-x
[40] T. Rygh, C. Vaage, S. Westgaard, & P. Lange, "Inflation Forecasting: LSTM Networks vs. Traditional Models for Accurate Predictions", Journal of Risk and Financial Management, vol. 18, no. 7, pp. 365, 2025. https://doi.org/10.3390/jrfm18070365
[41] V. Teodorescu and L. Brașoveanu, "Assessing the Validity of k-Fold Cross-Validation for Model Selection: Evidence from Bankruptcy Prediction Using Random Forest and XGBoost", Computation, vol. 13, no. 5, pp. 127, 2025. https://doi.org/10.3390/computation13050127
[42] K. Kinast and E. Fokoué, "An In-Depth Look at Rising Temperatures: Forecasting with Advanced Time Series Models in Major US Regions", Forecasting, vol. 6, no. 3, pp. 815-838, 2024. https://doi.org/10.3390/forecast6030041
[43] L. Alsmadi, G. Lei, & L. Li, "Forecasting Day-Ahead Electricity Demand in Australia Using a CNN-LSTM Model with an Attention Mechanism", Applied Sciences, vol. 15, no. 7, pp. 3829, 2025. https://doi.org/10.3390/app15073829
[44] T. Dinh, G. Thirunavukkarasu, M. Seyedmahmoudian, S. Mekhilef, & A. Stojcevski, "Predicting Commercial Building Energy Consumption Using a Multivariate Multilayered Long-Short Term Memory Time-Series Model", Applied Sciences, vol. 13, no. 13, pp. 7775, 2023. https://doi.org/10.3390/app13137775
[45] M. Diqi, I. Ordiyasa, & H. Hamzah, "Enhancing Stock Price Prediction Using Stacked Long Short-Term Memory", IT Journal Research and Development, vol. 8, no. 2, pp. 164-174, 2024. https://doi.org/10.25299/itjrd.2023.13486
[46] Z. Wang, "Stock Price Prediction using LSTM Neural Networks: Techniques and Applications", Applied and Computational Engineering, vol. 86, no. 1, pp. 294-300, 2024. https://doi.org/10.54254/2755-2721/86/20241605
[47] F. Peng, X. Ji, L. Zhang, J. Wang, K. Zhang, & W. Wu, "Interpretable Mixture of Experts for Decomposition Network on Server Performance Metrics Forecasting", Electronics, vol. 13, no. 20, pp. 4116, 2024. https://doi.org/10.3390/electronics13204116
[48] C. Lei, H. Zhang, W. Zhi-gang, & Q. Miao, "Deep Learning for Demand Forecasting: A Framework Incorporating Variational Mode Decomposition and Attention Mechanism", Processes, vol. 13, no. 2, pp. 594, 2025. https://doi.org/10.3390/pr13020594
[49] M. Abumohsen, A. Owda, & M. Owda, "Electrical Load Forecasting Using LSTM, GRU, and RNN Algorithms", Energies, vol. 16, no. 5, pp. 2283, 2023. https://doi.org/10.3390/en16052283
[50] C. Lei, H. Zhang, W. Zhi-gang, & Q. Miao, "Multi-Model Fusion Demand Forecasting Framework Based on Attention Mechanism", Processes, vol. 12, no. 11, pp. 2612, 2024. https://doi.org/10.3390/pr12112612
[51] J. Olaniyan, D. Olaniyan, I. Obagbuwa, B. Esiefarienrhe, A. Adebiyi, & O. Bernard, "Intelligent Financial Forecasting with Granger Causality and Correlation Analysis Using Bayesian Optimization and Long Short-Term Memory", Electronics, vol. 13, no. 22, pp. 4408, 2024. https://doi.org/10.3390/electronics13224408
[52] C. Xu, P. Coen-Pirani, & X. Jiang, "Empirical Study of Overfitting in Deep Learning for Predicting Breast Cancer Metastasis", Cancers, vol. 15, no. 7, pp. 1969, 2023. https://doi.org/10.3390/cancers15071969
[53] A. Rezaeezade and L. Batina, "Regularizers to the Rescue: Fighting Overfitting in Deep Learning-based Side-channel Analysis", Journal of Cryptographic Engineering, vol. 14, no. 4, pp. 609-629, 2024. https://doi.org/10.1007/s13389-024-00361-5
[54] E. Chollet, A. Scheidegger, J. Wydler, & N. Schuwirth, "A Comparison of Machine Learning and Statistical Species Distribution Models: Quantifying Overfitting Supports Model Interpretation", Ecological Modelling, vol. 481, pp. 110353, 2023. https://doi.org/10.1016/j.ecolmodel.2023.110353
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2025 Rifki Ainul Yaqin

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Abstract views: 0
,
PDF Downloads: 0





