Predict Goods Demand Using the XGBoost Method Based on Sales Historical Data
DOI:
https://doi.org/10.30865/jurikom.v13i2.9584Keywords:
Sales Historical Data, Machine Learning, Demand Prediction, XGBoost, Time SeriesAbstract
Predicting the demand for goods is an important aspect of inventory management and operational planning because inaccurate predictions can lead to overstock or shortages of goods. This study aims to predict the demand for goods using the Extreme Gradient Boosting (XGBoost) algorithm based on historical sales data. The dataset used contains information on the transaction date, number of sales, stock, price, and time index, which is then processed through the preprocessing and feature engineering stages, including the formation of temporal features and sales lag features. Data sharing is carried out using a time series split approach to maintain the chronological order of the data. The XGBoost model is optimized using GridSearchCV with the TimeSeriesSplit validation scheme. Model performance was evaluated using Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), Mean Absolute Percentage Error (MAPE), and Symmetric Mean Absolute Percentage Error (SMAPE). The results showed that the model produced an MAE score of 54.13 and an RMSE of 77.60, while a SMAPE score of 43.13% showed an acceptable relative error rate in highly fluctuating sales data. Feature importance analysis shows that previous period (lag_1) sales and weekly patterns are the most dominant factors in demand predictions. These results prove that XGBoost is effectively used for historical data-driven demand prediction of goods and has the potential to support inventory management decision-making.
References
[1] D. N. Gono, H. Napitupulu, and Firdaniza, “Silver Price Forecasting Using Extreme Gradient Boosting (XGBoost) Method,” Mathematics, vol. 11, no. 18, 2023, doi: 10.3390/math11183813.
[2] S. Malik, M. Khan, M. K. Abid, and N. Aslam, “Sales Forecasting Using Machine Learning Algorithm in the Retail Sector,” vol. 06, no. 02, 2024.
[3] J. Garcke and R. Roscher, “Explainable Machine Learning,” Mach. Learn. Knowl. Extr., vol. 5, no. 1, pp. 169–170, 2023, doi: 10.3390/make5010010.
[4] A. K. Konyaliouglu, T. B. Apaydin, .Ilhan Turhan, A. Soydal, and T. Özcan, “An Extreme Gradient Boosting Model Optimized with Genetic Algorithm for Sales Forecasting of Retail Stores,” in Industrial Engineering in the Industry 4.0 Era, N. M. Durakbasa and M. G. Gençyilmaz, Eds., Cham: Springer Nature Switzerland, 2024, pp. 59–67.
[5] H. Xie, S. Chen, C. Lai, G. Ma, and W. Huang, “Forecasting the clearing price in the day-ahead spot market using eXtreme Gradient Boosting,” Electr. Eng., vol. 104, no. 3, pp. 1607–1621, 2022, doi: 10.1007/s00202-021-01410-6.
[6] A. Panarese, G. Settanni, V. Vitti, and A. Galiano, “Developing and Preliminary Testing of a Machine Learning-Based Platform for Sales Forecasting Using a Gradient Boosting Approach,” Appl. Sci., vol. 12, no. 21, 2022, doi: 10.3390/app122111054.
[7] A. K. Sharma, L.-H. Li, and R. Ahmad, “Default Risk Prediction Using Random Forest and XGBoosting Classifier BT - 2021 International Conference on Security and Information Technologies with AI, Internet Computing and Big-data Applications,” G. A. Tsihrintzis, S.-J. Wang, and I.-C. Lin, Eds., Cham: Springer International Publishing, 2023, pp. 91–101.
[8] P. H. Vuong, T. T. Dat, T. K. Mai, P. H. Uyen, and P. T. Bao, “Stock-Price Forecasting Based on XGBoost and LSTM,” 2022, doi: 10.32604/csse.2022.017685.
[9] M. Dehvari, S. Farzaneh, and E. Forootan, “Forecasting rainfall events based on zenith wet delay time series utilizing eXtreme gradient boosting (XGBoost),” Adv. Sp. Res., vol. 75, no. 3, pp. 2584–2598, 2025, doi: https://doi.org/10.1016/j.asr.2024.11.013.
[10] S. Ben Jabeur, S. Mefteh-Wali, and J. L. Viviani, “Forecasting gold price with the XGBoost algorithm and SHAP interaction values,” Ann. Oper. Res., vol. 334, no. 1–3, 2024, doi: 10.1007/s10479-021-04187-w.
[11] W. A. Nugroho, F. D. Rachman, B. K. Siahu, I. A. Iswanto, and S. Joddy, “Hybrid Ensemble Model Approaches for Stock Price Forecasting Using LSTM, Random Forest, ARIMA, and Linear Regression as Meta-Learner,” Procedia Comput. Sci., vol. 269, pp. 901–910, 2025, doi: https://doi.org/10.1016/j.procs.2025.09.033.
[12] N. Rofiq and S. L. M. Sitio, Pengenalan Dasar Analisis Data dengan Python di Google Colab. Eureka Media Aksara, 2024.
[13] R. Natras, B. Soja, and M. Schmidt, “Ensemble Machine Learning of Random Forest, AdaBoost and XGBoost for Vertical Total Electron Content Forecasting,” Remote Sens., vol. 14, no. 15, 2022, doi: 10.3390/rs14153547.
[14] G. Behera, A. Bhoi, and A. K. Bhoi, “A Comparative Analysis of Weekly Sales Forecasting Using Regression Techniques,” in Intelligent Systems, S. K. Udgata, S. Sethi, and X.-Z. Gao, Eds., Singapore: Springer Nature Singapore, 2022, pp. 31–43.
[15] Jan Melvin Ayu Soraya Dachi and Pardomuan Sitompul, “Analisis Perbandingan Algoritma XGBoost dan Algoritma Random Forest Ensemble Learning pada Klasifikasi Keputusan Kredit,” J. Ris. Rumpun Mat. Dan Ilmu Pengetah. Alam, vol. 2, no. 2, pp. 87–103, 2023, doi: 10.55606/jurrimipa.v2i2.1470.
[16] S. L. M. Sitio et al., “Comparison of the Ensemble Xgboost and Transformer Models With Machine Learning for Classification of Indonesian Music Moods of the 70’S and 80’S Era,” J. Theor. Appl. Inf. Technol., vol. 102, no. 24, pp. 9157–9165, 2024.
[17] M. Mohamed, F. E. Mahmood, M. A. Abd, M. Rezkallah, A. Hamadi, and A. Chandra, “Load Demand Forecasting Using eXtreme Gradient Boosting (XGboost),” in 2023 IEEE Industry Applications Society Annual Meeting (IAS), 2023, pp. 1–7. doi: 10.1109/IAS54024.2023.10406613.
[18] K. K. Yun, S. W. Yoon, and D. Won, “Prediction of stock price direction using a hybrid GA-XGBoost algorithm with a three-stage feature engineering process,” Expert Syst. Appl., vol. 186, p. 115716, 2021, doi: https://doi.org/10.1016/j.eswa.2021.115716.
[19] M. Hisyam, Z. Fitri, H. Al, and K. Aidilof, “Implementasi Algoritma XGBoost dengan Walk Forward Validation untuk Prediksi Harga Emas Antam,” vol. 12, no. 4, pp. 403–413, 2025, doi: 10.30865/jurikom.v12i4.8693.
[20] A. Mitra, A. Jain, A. Kishore, and P. Kumar, “A Comparative Study of Demand Forecasting Models for a Multi-Channel Retail Company: A Novel Hybrid Machine Learning Approach,” Oper. Res. Forum, vol. 3, no. 4, p. 58, 2022, doi: 10.1007/s43069-022-00166-4.
[21] S. Sharma and P. Chaudhary, “Machine learning and deep learning,” Quantum Comput. Artif. Intell. Train. Mach. Deep Learn. Algorithms Quantum Comput., pp. 71–84, 2023, doi: 10.1515/9783110791402-004.



