Segmentation-based Monthly and Weekly Revenue Prediction using K-Means Clustering and XGBoost
Author
Hla Pyae Hein, Lai Yee Win Lwin
Abstract
There exists substantial fluctuation in retail transaction data among customers, items, regions, and seasons, complicating reliable revenue predictions for Small and Medium-sized Enterprises (SMEs). To address these issues, this research introduces a forecasting framework based on segmentation that integrates K-Means clustering with Local XGBoost for predicting retail revenue on a weekly and monthly basis. The framework is constructed on the Online Retail II dataset and executes segmentation at the customer, product, and geographic tiers prior to forecasting. A chronological data-processing approach is used to maintain the correct temporal sequence. Weekly and monthly revenue series are then constructed for each cluster, together with forecasting features based on historical lags, rolling statistics, seasonal patterns, and holiday indicators. Separate XGBoost models are trained for each segment, while a Direct XGBoost model without clustering serves as the main benchmark for comparison. Model performance is evaluated using Weighted Absolute Percentage Error (WAPE), including mean, holiday-period, and worst-fold performance. The proposed approach achieved a mean WAPE of 19.22%, compared with 24.60% for Direct XGBoost, and also obtained lower errors in the reported holiday-period and worst-fold evaluations. The findings suggest that segmentation can provide useful predictive structure by allowing forecasting models to learn more localized revenue behavior. However, periods of strong seasonal variation remain more difficult to predict, indicating opportunities for further improvement in retail forecasting under volatile conditions.
Keywords
K-Means clustering, XGBoost, retail revenue forecasting, customer segmentation, time-series forecasting, SMEs.
Full Text:
Download Paper PDF
References
- Chen, “Online Retail II,” UCI Machine Learning Repository, 2019. DOI: 10.24432/C5CG6D.
- MacQueen, “Some methods for classification and analysis of multivariate observations,” Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability, pp. 281–297, 1967.
- Chen and C. Guestrin, “XGBoost: A scalable tree boosting system,” Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 785–794, 2016.
- N. Astakhova, L. A. Demidova, and E. V. Nikulchev, “Forecasting Method for Grouped Time Series with the Use of k-Means Algorithm,” Applied Mathematical Sciences, vol. 9, no. 97, pp. 4813–4830, 2015. DOI: 10.12988/ams.2015.55391.
- Tang, Y. Jiao, and M. Yuan, “RFM user value tags and XGBoost algorithm for analyzing electricity customer demand data,” Systems and Soft Computing, vol. 6, 200098, 2024. DOI: 10.1016/j.sasc.2024.200098.
- Hwang, Y. Lee, B.-K. Jeon, and S. H. Oh, “Sales Forecasting for New Products Using Homogeneity-Based Clustering and Ensemble Method,” Electronics, vol. 14, no. 3, p. 520, 2025. DOI: 10.3390/electronics14030520.
- Seyedan, F. Mafakheri, and C. Wang, “Cluster-based demand forecasting using Bayesian model averaging: An ensemble learning approach,” Decision Analytics Journal, vol. 3, 100033, 2022. DOI: 10.1016/j.dajour.2022.100033.
- Goverdhan, S. Khare, and M. R, “Time Series Prediction: Comparative Study of ML Models in the Stock Market,” Research Article, 2022. DOI: 10.21203/rs.3.rs-2183122/v1.
- Ji, X. Wang, W. Zhao, and D. Guo, “An Application of a Three-Stage XGBoost-Based Model to Sales Forecasting of a Cross-Border E-Commerce Enterprise,” Mathematical Problems in Engineering, vol. 2019, Article ID 8503252, 2019. DOI: 10.1155/2019/8503252.
Share your valuable work from Social Media Buttons