Stock Price Prediction of PT Kalbe Farma Tbk Using the Extreme Gradient Boosting (XGBOOST)

Author's Information:

Chandra Putra Ciptaningtyas

Department of  Statistics, Faculty of Science and Mathematics, Universitas Diponegoro, Semarang, Indonesia

Triastuti Wuryandari

Department of  Statistics, Faculty of Science and Mathematics, Universitas Diponegoro, Semarang, Indonesia

Miftahul Jannah

Department of  Statistics, Faculty of Science and Mathematics, Universitas Diponegoro, Semarang, Indonesia

Vol 02 No 11 (2025):Volume 02 Issue 11 November 2025

Page No.: 350-358

Abstract:

Stock price prediction is crucial in investment decision - making due to its dynamic and volatile nature. Fluctuations in stock prices are influenced by macroeconomic indicators, market sentiment, and global financial conditions, resulting in complex and non-linear patterns that traditional modelsstruggle to capture. PT Kalbe Farma Tbk  shares are among the leading stocks in the pharmaceutical sector listed on the Indonesia Stock Exchange.  This study employs Extreme Gradient Boosting (XGBoost) to predict PT Kalbe Farma Tbk closing stock price. XGBoost was leveraging its ability to process time series data and model intricate dependencies. XGBoost was chosen for its efficiency in handling large datasets, managing missing values, and applying regularization to prevent overfitting. To enhance model performance ensuring accuracy, robustness, and generalization Particle Swarm Optimization (PSO)and GridSearchCV. PSO and GridSearchCV are used for hyperparameter tuning. PSO is a swarm intelligence-based algorithm, mimics collective behaviors in nature, refining parameters through individual and group adaptation. Meanwhile, GridSearchCV systematically explores parameter spacesvia cross-validation to select optimal configurations. The model was evaluated using Mean Absolute Percentage Error (MAPE). Based on the analysis result, it shows that XGBoost withoutoptimization has a MAPE of 1.78, while optimization with PSO, the MAPE is reduced to 1.46, and GridSearchCV, the MAPE achieved 1.58. These results confirm that PSO and GridSearchCV improve XGBoost’s predictive accuracy, making it a reliable method for financial market forecasting

KeyWords:

PT Kalbe Farma Tbk; Particle Swarm Optimization; GridSearchCV; XGBoost

References:

  1. Alzubi, J., Nayyar, A., & Kumar, A. (2018).Machine Learning from Theory to Algorithms: An Overview. Journal of Physics: Conference Series, 1142(1). https://doi.org/10.1088/1742-6596/1142/1/012012
  2. Bartz, E., Bartz-Beielstein, T., Zaefferer, M., & Mersmann, O. (2023). Hyperparameter Tuning for Machine and Deep Learning with R: A Practical Guide.In Hyperparameter Tuning for Machine and Deep Learning with R: A Practical Guide. https://doi.org/10.1007/978-981-19-5170-1
  3. Bergstra, J., & Bengio,Y. (2012). Randomsearch for hyper-parameter optimization. Journal of Machine Learning Research, 13, 281–305.
  4. Cahyani, C. P., Permadhy, Y. T., & Aziz, A. (2021). Analisis ReturnSaham LQ45 di Bursa Efek Indonesia. Konferensi Riset NasionalEkonomi, Manajemen, dan Akuntansi, 2,  pp.349-361.
  5. Chai, T., & Draxler, R. R. (2014). Root mean square error (RMSE) or mean absolute error (MAE) - Arguments against avoiding RMSE in the literature. Geoscientific Model Development, 7(3), 1247–1250. https://doi.org/10.5194/gmd-7-1247-2014
  6. Chen, T., & Guestrin,C. (2016). XGBoost:A Scalable Tree Boosting System. Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (pp. 785-794). ACM (Association for Computing Machinery). https://doi.org/10.1145/2939672.2939785
  7. Eberhart, R., & Kennedy, J. (1995). ParticleSwarm Optimization. Proceedings of the IEEE International Conference on Neural Networks, 1942-1948. https://doi.org/10.1109/ICNN.1995.488968
  8. Hyndman, R. J., & Athanasopoulos, G. (2018). Forecasting: Principles and Practice (2nd ed.). OTexts.
  9. Kasmir. (2009).Analisis Laporan Keuangan. Jakarta: PT. RajaGrafindo Persada.
  10. Kuhn, M., & Johnson, K. (2013). Applied Predictive Modeling. New York: Springer. https://doi.org/10.1007/978-1-4614-6849-3
  11. Liu, J. J., & Liu, J. C. (2022).Permeability Predictions for Tight Sandstone Reservoir Using Explainable Machine Learningand Particle Swarm Optimization. Geofluids, 2022(2). https://doi.org/10.1155/2022/2263329
  12. Moritz, S., & Beielstein, T. M. (2017). imputeTS: Time Series Missing Values Imputation in R. The R Journal, 9(1), 207-218. https://doi.org/10.32614/RJ-2017-009
  13. Pramudhyta, N. A., & Rohman, M. S. (2024). Perbandingan OptimasiMetode Grid Search dan Random Search dalam Algoritma XGBoost untuk Klasifikasi Stunting. Jurnal Media Informatika Budidarma  vol 8 No 1, 19-29. https://doi.org/10.30865/mib.v8i1.6965
  14. Sanyal, S. (2023). An Introduction to Particle Swarm Optimization (PSO Algorithm). Retrieved from Analytics Vidhya: https://www.analyticsvidhya.com/blog/2021/10/an- introduction-to-particle-swarm-optimization-algorithm/
  15. Snoek, J., Larochelle, H., & Adams, R. P. (2012). Practical Bayesian Optimization of Machine Learning Algorithms. Advances in Neural Information Processing Systems, 25, 2951–2959. https://arxiv.org/abs/1206.2944 
  16. Sokolova, M., & Lapalme, G. (2009). A systematic analysis of performance measures for classification tasks. Information Processing & Management, 45(4), 427-437. https://doi.org/10.1016/j.ipm.2009.03.002
  17. Uhunmwangho, O. P. (2024). Comparing XGBoost and LSTM Models for Prediction of Microsoft Corp's Stock Price Direction. Mountain Top University Journal of Applied Science and Technology (MUJAST), 4(2), 64-88. 
  18. .Undang-Undang Republik Indonesia Nomor 8 Tahun 1995 tentang Pasar Modal. (1995). Jakarta: Sekretariat Negara Republik Indonesia.
  19. Yang, Y., Wu, Y., Wang, P., & Xujiali. (2021). Stock Price Prediction Based on XGBoost and LightGBM. E3S Web of Conferences, 275, 01040. https://doi.org/10.1051/e3sconf/202127501040