Introduction
Sales forecasting of products in retail and e-commerce-related environments represents one of the key areas of machine learning application in business solutions, as it directly supports decisions concerning inventory management, promotion planning, pricing policy, the allocation of marketing budgets, and the optimization of operational processes (Fildes et al., 2022). In online and data-driven retail, the accuracy of forecasts is of particular importance, since product sales depend not only on historical demand but also on pricing, promotional, seasonal, logistical, and behavioural factors, such as customer activity, event-related demand fluctuations, and changes in purchasing patterns (Ferreira et al., 2016). The classical forecasting literature indicates that demand forecasting is a decision-making process whose goal is not solely to minimize statistical error, but also to provide information useful for the planning of business activities (Hyndman & Athanasopoulos, 2018).
In the e-commerce and retail environment, the multidimensionality of data plays a particularly important role, as product sales may be determined simultaneously by product, pricing, seasonal, promotional, inventory, logistical, and behavioural variables. Research on online sales has shown that data characteristic of digital channels - such as product description content, marketing phrases, or signals of user activity - can improve the effectiveness of sales prediction (S. Chen et al., 2024). Public and anonymized retail benchmarks are therefore particularly valuable, because they make it possible to test forecasting procedures on real transactional sales patterns without direct access to confidential firm-level systems. The Walmart M5 dataset is especially relevant in this context, as it provides hierarchical product-level sales data, calendar information, and price-related variables for a large-scale retail forecasting problem (Makridakis et al., 2020, 2022; Spiliotis et al., 2022).
Previous research on sales forecasting has evolved from classical time series and regression models toward machine learning and deep learning methods. Statistical and econometric models remain an important reference point, but their limitation often lies in the difficulty of capturing complex, nonlinear relationships among multiple input variables (John Lu, 2010). Research on forecast accuracy measures indicates that model evaluation should be conducted using several metrics, since a single error indicator may not reflect the full characteristics of a model’s predictive quality (Hyndman & Koehler, 2006). For this reason, predictive studies commonly employ metrics such as RMSE, MAE, and the coefficient of determination R², which make it possible to assess both the average magnitude of the error and the degree to which the variability of the predicted variable is explained (Nowak & Zajkowski, 2025).
The importance of the comparative evaluation of forecasting models is also confirmed by large-scale forecasting competitions, in particular the M4 and M5 competitions. The M4 competition encompassed 100,000 time series and 61 forecasting methods, demonstrating the importance of objective benchmarking in the evaluation of forecasting methods (Makridakis et al., 2020). The M5 competition focused directly on retail sales forecasting and required forecasts for 42,840 hierarchical Walmart unit-sales series, making it one of the most important reference points for research on product-level retail demand forecasting (Makridakis et al., 2022). The practical relevance of the M5 data has also been discussed from the perspective of Walmart’s forecasting process, while subsequent studies have examined the representativeness of the M5 data and the relationship between forecast accuracy and inventory performance (Theodorou et al., 2022, 2025). At the same time, the results of comparative studies indicate that machine learning methods do not automatically outperform classical statistical methods, and their effectiveness depends on the structure of the data, the quality of features, the validation procedure, and the nature of the predictive problem. This justifies the necessity of empirically comparing multiple models on the same dataset.
Recent empirical studies on retail forecasting confirm the relevance of machine learning methods for product-level and SKU-level demand prediction. Huber and Stuckenschmidt (2020) demonstrated that machine learning models can improve daily retail demand forecasting when calendar-related special days are explicitly represented in the feature set. Ma and Fildes (2021) proposed a meta-learning approach for retail sales forecasting, showing that forecast performance depends on the characteristics of the sales series and the selection of appropriate modelling strategies. Spiliotis et al. (2022) compared statistical and machine learning methods for daily SKU demand forecasting and emphasized the importance of cross-learning across related sales series. More recently, Wellens et al. (2024) showed that simplified tree-based methods with explanatory variables can achieve strong performance in retail sales forecasting while remaining interpretable through Shapley-based explanations. These studies support the use of tabular, feature-based ML models in retail forecasting problems and justify the inclusion of calendar, product hierarchy, price-related, and historical demand variables in the present study.
Various classes of regression algorithms find application in sales prediction. Ridge regression extends linear modelling by introducing L2 regularization, which can reduce estimation instability in the presence of correlated predictors, such as lagged sales values, rolling averages, and price-related variables (Hoerl & Kennard, 1970). Tree-based ensemble methods are particularly relevant for retail forecasting because they can capture nonlinear relationships and interactions among product, calendar, price, and historical demand features. Random Forest improves the stability of individual trees through aggregation over multiple estimators trained on random samples and feature subsets (Breiman, 2001), while Extra Trees introduces additional randomization in split selection, which may reduce variance in tabular prediction problems. Gradient boosting methods are also widely used for structured data forecasting. XGBoost was designed as a scalable tree boosting system (T. Chen & Guestrin, 2016), whereas LightGBM improves computational efficiency through optimized tree growth and sampling mechanisms (Ke et al., 2017). These algorithms are therefore appropriate for benchmarking product-level retail sales prediction on tabular data with heterogeneous explanatory variables.
In parallel, the field of deep learning for time series forecasting has been developing, encompassing, among others, recurrent models, probabilistic architectures, and transformers. DeepAR demonstrates that training a single model on multiple related time series can support probabilistic demand forecasting in business applications (Salinas et al., 2020). The Temporal Fusion Transformer combines multi-horizon forecasting with interpretability components, which addresses business needs in which not only the accuracy of the forecast but also the understanding of the influence of input variables is important (Lim et al., 2021). N-BEATS represents an example of a neural architecture designed specifically for time series forecasting and partially interpretable through trend and seasonality components (Oreshkin et al., 2019). However, literature reviews indicate that deep learning in forecasting requires large datasets, greater computational resources, and careful validation, and therefore, in many business applications, classical ML regression algorithms and tree-based ensembles remain a justified, efficient, and more easily implementable starting point (Benidis et al., 2022).
An important requirement for models applied in business is not only the accuracy of predictions but also their interpretability. This is particularly relevant for tree-based ensemble and boosting models, which may achieve high predictive accuracy but remain difficult to translate into managerial decision rules. In sales and demand forecasting, recent studies increasingly combine predictive models with explanation methods to support decision-making in retail and e-commerce contexts (S. Chen et al., 2024; Wang & Zhang, 2024; Wellens et al., 2024). The importance of model interpretability is also emphasized by research on local explanations of predictions, in which the explanation of a model’s decision is treated as a condition for the user’s trust in the predictive system (Ribeiro et al., 2016). The SHAP method, based on Shapley values from cooperative game theory, makes it possible to assign individual features a contribution to a single model prediction (Lundberg & Lee, 2017; Shapley & others, 1953). Permutation Feature Importance, in turn, measures the decrease in predictive quality after random permutation of a given feature, which makes it possible to assess which variables the model most strongly relies on during prediction (Breiman, 2001; Fisher et al., 2019). The combination of SHAP and PFI is particularly useful in business analysis, since PFI indicates the importance of features for the quality of predictions, while SHAP makes it possible to determine the direction and magnitude of the influence of features on predicted sales.
However, feature importance analysis does not fully explain whether a given factor is merely influential or whether it constitutes a necessary condition for achieving high sales levels. From a managerial perspective, this distinction is important. A variable may not be sufficient to generate high sales by itself, but a minimum level of this variable may be required for high sales to occur. Necessary Condition Analysis addresses this issue by identifying bottleneck-like conditions and threshold values associated with high outcome levels (Dul, 2016). NCA is based on a necessary-but-not-sufficient logic: the absence of a necessary condition prevents a high outcome, although the presence of that condition does not guarantee it. The method has been further developed through statistical significance testing and methodological guidelines for good practice (Dul et al., 2020, 2023), as well as through a broader causal perspective emphasizing the distinct role of necessary conditions in empirical research (Dul, 2024). In the context of sales forecasting, NCA may therefore complement ML and XAI methods by translating predictive features into interpretable threshold conditions. This makes it possible to move beyond the question of which variables are important for predictions toward the question of which minimum conditions must be present for high sales levels to be feasible.
Based on the literature review, it is possible to identify a research gap related to the need to develop a compact, replicable procedure for predicting product sales that would combine the benchmarking of multiple regression algorithms, model interpretability analysis, and threshold-oriented necessary condition analysis from a business perspective. Many studies focus either on forecasting accuracy alone or on advanced deep learning architectures, which are more difficult to deploy and explain in typical business conditions. Less attention, in turn, has been devoted to procedures that employ real product-level retail data, compare classical and ensemble ML models, apply PFI and SHAP as tools supporting the interpretation of results, and additionally identify necessary conditions for achieving high sales outcomes. This gap is particularly important from the perspective of AI and data science in business solutions, since the practical value of a predictive model depends both on its statistical quality and on the ability to translate the results into operational decision rules.
The research problem of this article can be formulated as follows: which of the selected machine learning regression algorithms ensures the highest accuracy of product sales prediction in real retail sales data, which features have the greatest influence on the predicted number of units sold, and which of these features constitute necessary conditions for achieving high sales levels? The aim of this article is to develop and evaluate a predictive model for product sales forecasting using the benchmarking of selected ML regression algorithms together with PFI, SHAP, and Necessary Condition Analysis. The study employs the Walmart M5 sales forecasting dataset, including calendar, product hierarchy, event-related, price-related, and historical sales features. In the empirical part, six models are compared: a naive weekly benchmark, Ridge regression, Random Forest, Extra Trees, XGBoost, and LightGBM. The evaluation of model quality is performed on the basis of RMSE, MAE, R², WMAPE, and RMSSE metrics, taking into account rolling-origin validation and a final 28-day test period. The most effective model is then subjected to an interpretability analysis using PFI and SHAP, followed by NCA, which makes it possible to identify threshold-like bottlenecks associated with high sales levels.
The structure of the article is as follows. The Methods section presents the research procedure, encompassing the development of the database, the preparation of variables, the implementation of the ML algorithms, the manner of evaluating predictive quality, and the application of PFI, SHAP, and NCA. The Results section presents the results of the regression model benchmarking, the selection of the most effective algorithm, the interpretation of feature importance using PFI and SHAP, and the identification of necessary conditions using NCA. The Discussion section addresses the significance of the obtained results for business applications in retail and e-commerce-related sales management, in particular for inventory management, pricing policy, promotion planning, and the assessment of high-sales potential. The Conclusion section presents the main findings, the limitations of the study, and directions for further work, including the possibility of extending the analysis to broader real-world transactional data, probabilistic models, deep learning architectures, and multi-horizon forecasting.