This project is an end-to-end Customer Segmentation and Personalization System. It goes beyond traditional clustering by integrating deep behavioral analytics, predictive machine learning, explainable AI (SHAP), and an automated business strategy generator.
- Data Preprocessing Layer (
src/data_processing.py): Handles ingestion, missing values, and feature engineering (calculating RFM metrics, Average Order Value, and Customer Lifetime Value proxy). It also normalizes the data for clustering. - Intelligent Segmentation Engine (
src/segmentation.py): Implements K-Means, DBSCAN, Hierarchical Clustering, and Gaussian Mixture Models. Evaluates them dynamically using Silhouette and Davies-Bouldin scores to find optimal customer segments (e.g., High-Value Loyal vs. At-Risk). - Predictive Intelligence (
src/predictive_models.py): Trains multiple models (XGBoost, Random Forest, Logistic Regression) to predict Customer Churn and forecasts future spending (CLV). - Explainable AI (
src/explainability.py): Leverages SHAP (SHapley Additive exPlanations) to provide feature-level transparency into the predictive models (e.g., Why is this customer churning?). - Recommendation Engine (
src/recommendation.py): Uses collaborative filtering to power cross-selling and product recommendations tailored to specific segments and individual transaction histories. - Strategy Generator (
src/strategy_generator.py): Automatically interprets segment statistics into concrete, actionable business plans. - Interactive Dashboard (
app.py): A complete Streamlit web application that unites all the ML modules into a cohesive, interactive UI.
- Data & ML: Python, Pandas, NumPy, Scikit-Learn, XGBoost, SHAP
- Visualization: Plotly Express, Matplotlib, Seaborn
- Web App: Streamlit
- Ensure Python 3.10+ is installed.
- Install dependencies:
pip install -r requirements.txt
- Generate the synthetic dataset (if not already done):
python src/data_generator.py
- Run the Streamlit Dashboard:
streamlit run app.py
- Open
http://localhost:8501in your browser.
This repository is 100% deployment-ready.
- For Streamlit Community Cloud / Hugging Face Spaces: Simply connect this GitHub repository and select
app.pyas the entry point. The platform will automatically installrequirements.txt. - For Render: Use a Python web service environment, set the start command to
streamlit run app.py --server.port $PORT, and it will deploy seamlessly.
Built by Antigravity