Comparative Analysis of Machine Learning and Statistical Models for E-Commerce Sales Forecasting
Abstract
Accurate sales forecasting in e-commerce market-places is critical for optimizing inventory management and strategic marketing decisions across diverse product categories. This study presents a quantitative comparative evaluation of six fore-casting models applied to weekly sales demand. Statistical models including Naive, ARIMA, SARIMA, and Prophet were evaluated alongside supervised machine learning algorithms including Random Forest and XGBoost. The experimental dataset was derived from the Brazilian E-Commerce Public Dataset by Olist, comprising 96,095 delivered orders aggregated into 91 weekly observations from week 40 of 2016 to week 27 of 2018 across the top five revenue categories. Feature engineering produced lag variables, rolling statistics, and calendar attributes to capture sequential and temporal patterns. Evaluation was conducted using a chronological train-test split, reserving the initial 73 weeks for training and the remaining 18 weeks for testing, alongside rolling-origin cross-validation. Predictive accuracy was assessed using Mean Absolute Error, Root Mean Squared Error, and Mean Absolute Percentage Error. Experimental results demonstrate that XGBoost achieved the highest performance, recording the lowest average Mean Absolute Percentage Error of 18.9%, Root Mean Squared Error of BRL 7,945, and Mean Absolute Error of BRL 4,796. Random Forest achieved 20.8% Mean Absolute Percentage Error, whereas Prophet, SARIMA, ARIMA, and Naive baselines yielded 23.5%, 25.5%, 27.6%, and 32.4%, respectively. Statistical significance testing using Diebold-Mariano tests confirmed that XGBoost significantly outperformed statistical models in 18 out of 20 category comparisons. E-commerce practitioners can leverage these empirical findings to integrate gradient-boosted ensemble models into business intelligence analytics dashboards for reliable category-level demand forecasting.