Explainable Machine Learning and Necessary Condition Analysis for Product Sales Forecasting in Retail
DOI:
https://doi.org/10.37256/est.81202710392Keywords:
sales forecasting, retail forecasting, machine learning, Explainable Artificial Intelligence (AI), Necessary Condition Analysis (NCA)Abstract
Sales forecasting in retail and e-commerce-related environments supports key decisions concerning inventory management, promotion planning, pricing policy, and sales strategy optimization. The aim of this article is to develop a predictive framework for product sales forecasting using machine learning regression algorithms, Explainable Artificial Intelligence (AI) methods, and Necessary Condition Analysis (NCA). The study employed the Walmart M5 retail sales forecasting dataset, including daily product-level sales observations with calendar, product hierarchy, event-related, price-related, and historical demand features. The benchmark included a naive weekly model, Ridge regression, Random Forest, Extra Trees, eXtreme Gradient Boosting (XGBoost), and Light Gradient Boosting Machine (LightGBM). Predictive performance was evaluated using Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), R2, Weighted Mean Absolute Percentage Error (WMAPE), and Root Mean Squared Scaled Error (RMSSE) under rolling-origin validation and on a final 28-day test period. The best-performing model was interpreted using Permutation Feature Importance and SHapley Additive exPlanations (SHAP), while NCA was applied to identify threshold-like bottlenecks associated with high sales outcomes. The results show that Extra Trees achieved the best test performance, with RMSE = 1.6183, MAE = 0.9109, R2 = 0.5852, WMAPE = 0.7708, and RMSSE = 0.7226. Permutation Feature Importance (PFI) and SHAP indicated that the most important predictors were rolling sales averages, product identity, weekend effects, SNAP-related information, and demand volatility. NCA further showed that selected rolling demand averages and volatility measures constituted necessary conditions for achieving high sales levels. The proposed Machine Learning (ML)-eXplainable Artificial Intelligence (XAI)-NCA framework therefore supports not only sales prediction but also the identification of interpretable demand thresholds relevant to retail decision-making.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 Marcin Nowak, Paweł Kościelniak

This work is licensed under a Creative Commons Attribution 4.0 International License.
