Retail and e-commerce businesses now accumulate enormous quantities of transaction, demographic, preference, and behavioral records. Manual review and fixed reports cannot easily turn such multi-dimensional data into usable insight, so firms find it hard to discover distinct customer groups, forecast buying patterns, and offer individually relevant products. Isolated statistical or machine learning scripts address only part of the problem; without one system that joins database queries, prediction, recommendation, natural-language assistance, and business intelligence, non-technical decision-makers rarely adopt them. We present ShopAI, an integrated machine learning and AI decision-support platform for customer shopping behavior. It brings together exploratory data analysis (EDA), SQL querying, unsupervised segmentation, supervised prediction, context-aware recommendation, and interactive visualization. Customers are grouped by K-Means clustering (K = 4) using age, purchase amount, review rating, previous purchases, purchase frequency, and discount usage, and Principal Component Analysis (PCA) maps the scaled features to three dimensions so the clusters can be inspected visually. A Random Forest Classifier estimates how likely a customer is to subscribe, and a Gradient Boosting Regressor forecasts purchase amount from demographic, seasonal, and transactional inputs. A custom feature engineering stage adds purchase frequency in days, age group, estimated annual spending, loyalty tier, subscriber indicator, and discount indicator. A PostgreSQL layer answers business questions on revenue by gender, discount sensitivity, loyalty, and product rankings. A hybrid Product Recommendation Engine combines gender, category, season, and K-Means cluster to return top-ranked items with numeric match scores and plain-language reasons, while an AI Shopping Behavior Copilot with a Marketing Strategy Synthesizer replies to natural-language questions using the underlying data. The system was built in Python (Pandas, NumPy, Scikit-learn, Joblib, Matplotlib, Seaborn, Plotly) on 3,900 customer shopping records, and is delivered as a Streamlit web application together with an executive Power BI dashboard. Checks covering 9 reusable model artifacts and 13 test cases show that the platform combines descriptive, predictive, and prescriptive analytics, helping analysts and marketing managers improve retention, targeting, and sales.
Introduction
The paper proposes ShopAI, an integrated machine learning and business intelligence system designed to analyze customer shopping behavior and help retailers make data-driven decisions. Traditional retail analysis relies on spreadsheets and static reports, which often fail to identify complex customer patterns, predict future purchases, or provide personalized marketing strategies. ShopAI addresses these limitations by combining data analysis, machine learning, recommendation systems, and AI-based decision support in a single platform.
The system analyzes 3,900 customer shopping records containing demographic, transactional, product, and behavioral information. It preprocesses the data and creates six additional features, including purchase frequency, age group, estimated annual spending, loyalty tier, subscriber status, and discount usage.
The main techniques used in ShopAI are:
K-Means Clustering: Groups customers into four behavioral segments based on their shopping patterns.
Principal Component Analysis (PCA): Reduces the data to three dimensions for visualizing customer segments in an interactive 3D graph.
Random Forest Classification: Predicts the likelihood that a customer will subscribe, providing a probability score between 0 and 1.
Gradient Boosting Regression: Estimates customer purchase amounts based on demographic and purchasing characteristics.
Context-Aware Recommendation System: Suggests the top three relevant products using customer segments, gender, product category, and season, with match scores and explanations.
AI Decision-Support Copilot: Answers business questions in natural language and generates personalized marketing strategies.
The paper also integrates PostgreSQL, Python, Streamlit, and Microsoft Power BI. PostgreSQL supports structured business queries and revenue analysis, while Streamlit provides an interactive interface for predictions and recommendations. Power BI enables executives to monitor key performance indicators (KPIs), evaluate promotions, and compare subscriber and non-subscriber behavior.
The literature review identifies several research gaps in existing retail analytics, including fragmented analytical workflows, limited subscription prediction, poor visualization of customer segments, unexplained recommendations, and a lack of AI-assisted decision-making. ShopAI aims to address these gaps through a unified and reproducible analytical framework.
The system is evaluated using clustering analysis, classification metrics such as accuracy, precision, recall, and F1-score, and regression metrics such as MAE, RMSE, and R². Automated verification is also used to check the nine saved model and data artifacts and the functionality of the system.
Conclusion
Understanding how customers shop is vital for retailers that want to keep customers, refine promotions, and grow revenue in competitive online markets. This paper introduced ShopAI, a Machine Learning & AI Decision-Support System for customer shopping behavior that integrates Python preprocessing, domain feature engineering, PostgreSQL analysis, K-Means clustering (K = 4), 3D PCA visualization, Random Forest subscription classification, Gradient Boosting purchase regression, a context-aware Product Recommendation Engine, and an AI Shopping Behavior Copilot. The framework tackles the fragmentation of traditional retail analytics by offering descriptive, predictive, and prescriptive capabilities in one interactive Streamlit application and an executive Power BI dashboard. Verified on 3,900 customer shopping records, 9 model artifacts, and 13 system test cases, it offers an accurate, interpretable, and practical basis for data-driven retail decisions.
References
[1] R. Mehta and S. Sehgal, “Micro-segmentation of retail customers using K-Means clustering and RFM characteristics,” IEEE Access, vol. 12, pp. 41205–41218, 2024.
[2] M. Hassan, “Empirical retail customer segmentation using RFM features, elbow analysis, and silhouette scoring in K-Means clustering,” Expert Systems with Applications, vol. 261, p. 125482, 2026.
[3] L. Breiman, “Random forests,” Machine Learning, vol. 45, no. 1, pp. 5–32, 2001.
[4] J. H. Friedman, “Greedy function approximation: A gradient boosting machine,” The Annals of Statistics, vol. 29, no. 5, pp. 1189–1232, 2001.
[5] G. Adomavicius and A. Tuzhilin, “Toward the next generation of recommender systems: A survey of the state-of-the-art and possible extensions,” IEEE Transactions on Knowledge and Data Engineering, vol. 17, no. 6, pp. 734–749, 2005.
[6] A. Christy, A. Umamakeswari, L. Priyatharsini, and A. Neyaa, “RFM ranking – An effective approach to customer segmentation,” Journal of King Saud University – Computer and Information Sciences, vol. 33, no. 10, pp. 1251–1257, 2021.
[7] S. Monalisa, P. Nadya, and R. Novita, “Analysis for customer lifetime value categorization with RFM model and K-Means clustering,” Procedia Computer Science, vol. 161, pp. 834–840, 2022.
[8] Y. Liu, H. Zhang, and K. Wang, “Customer subscription propensity and churn prediction in e-commerce using ensemble random forest models,” IEEE Transactions on Computational Social Systems, vol. 10, no. 4, pp. 1892–1904, 2023.
[9] P. Kumar, R. Sharma, and V. Gupta, “Predicting customer purchase value and spending behavior using gradient boosting machines,” Journal of Retailing and Consumer Services, vol. 76, p. 103584, 2024.
[10] C. Chen, L. Wu, and X. Li, “Dimensionality reduction and 3D visual analytics of high-dimensional consumer behavior using PCA and clustering,” IEEE Access, vol. 11, pp. 98412–98425, 2023.
[11] [K. Patel and D. Desai, “Context-aware hybrid product recommendation system based on customer segmentation and seasonal preferences,” Expert Systems with Applications, vol. 238, p. 122145, 2024.
[12] S. Verma, N. Joshi, and A. Kulkarni, “Integrating SQL data warehousing and business intelligence dashboards for retail decision support,” International Journal of Information Management Data Insights, vol. 4, no. 2, p. 100241, 2024.
[13] T. Nguyen, M. Tran, and H. Le, “AI-driven decision support and conversational copilots for automated retail marketing strategy,” Decision Support Systems, vol. 182, p. 114238, 2025.
[14] R. Bandara, J. Fernando, and S. Perera, “Multi-method framework combining RFM analysis, unsupervised clustering, and supervised learning for data-driven retail marketing,” Neural Computing and Applications, vol. 37, pp. 3410–3426, 2025.
[15] F. Pedregosa et al., “Scikit-learn: Machine learning in Python,” Journal of Machine Learning Research, vol. 12, pp. 2825–2830, 2011.