CoolFace
Apppublic

Tosa9/customer-segmentation-app

sourceHugging Faceupdated 4mo agoView on Hugging Face
1likes
App README

๐Ÿ›๏ธ Customer Segmentation โ€” K-Means Clustering

Group 9 | TechCrush AI/ML Programme

A deployed machine learning web app that segments mall customers into 5 distinct groups using K-Means clustering, built on the Mall Customer Segmentation dataset from Kaggle.


๐Ÿš€ Live App

Deployed on Streamlit Cloud โ€” [Add your link here after deployment]

๐Ÿ“ Repository Structure

customer-segmentation-app/
โ”‚
โ”œโ”€โ”€ app.py                      โ† Streamlit web application
โ”œโ”€โ”€ kmeans_primary_model.pkl    โ† Trained K-Means model (from notebook Section 11)
โ”œโ”€โ”€ scaler_2d.pkl               โ† Fitted StandardScaler (from notebook Section 11)
โ”œโ”€โ”€ Mall_Customers.csv          โ† Source dataset (from Kaggle)
โ”œโ”€โ”€ requirements.txt            โ† Python dependencies for Streamlit Cloud
โ””โ”€โ”€ README.md                   โ† This file

๐Ÿง  What the App Does

The app has two tabs:

Tab 1 โ€” Segment Predictor Enter a customer's Annual Income and Spending Score using sliders. The trained K-Means model instantly classifies them into one of 5 segments with a profile description and a recommended business action.

Tab 2 โ€” Cluster Visualisations Displays all major plots from the project notebook:

  • โ€”Hero cluster scatter plot (Income vs Spending Score)
  • โ€”Elbow method and Silhouette Score (how we chose k=5)
  • โ€”Per-sample silhouette coefficients
  • โ€”Cluster size distribution
  • โ€”Feature box plots per cluster
  • โ€”Radar chart (multi-feature cluster comparison)
  • โ€”Segment profile table with business actions
  • โ€”PCA projection of the extended 4-feature model
  • โ€”Correlation heatmap (EDA)

๐Ÿท๏ธ The 5 Customer Segments

ClusterSegmentProfileAction
0๐Ÿงฎ Careful SpendersMid income, low spendingValue bundles and loyalty programmes
1๐Ÿ’ฐ Budget ConsciousLow income, low spendingAffordable product lines only
2๐ŸŽฏ Target AudienceMid income, mid spendingBroad campaigns and seasonal promotions
3๐Ÿ’Ž High ValueHigh income, high spendingVIP treatment and premium products
4โšก Impulsive SpendersLow income, high spendingFlash sales and limited-time offers

๐Ÿ› ๏ธ Local Setup

bash
# Clone the repo
git clone https://github.com/Tosa9/customer-segmentation-app.git
cd customer-segmentation-app

# Install dependencies
pip install -r requirements.txt

# Run the app
streamlit run app.py

๐Ÿ“ฆ Generating the Model Files

The .pkl files are generated by running the full project notebook:

  1. 1.Open Group_9_Customer_Segmentation_Project.ipynb in Google Colab
  2. 2.Upload Mall_Customers.csv when prompted in Section 0
  3. 3.Run all cells through to Section 11
  4. 4.Download kmeans_primary_model.pkl and scaler_2d.pkl from the Colab file browser
  5. 5.Place them in this repo directory

๐Ÿ“Š Dataset

Mall Customer Segmentation Dataset Source: Kaggle โ€” vjchoudhary7 Records: 200 customers | Features: CustomerID, Gender, Age, Annual Income (k$), Spending Score (1-100)


๐Ÿ”ฌ Tech Stack

  • โ€”Python 3.10+
  • โ€”scikit-learn โ€” KMeans, StandardScaler, PCA, metrics
  • โ€”Streamlit โ€” Web app framework
  • โ€”pandas / numpy โ€” Data manipulation
  • โ€”matplotlib / seaborn โ€” Visualisations
  • โ€”scipy โ€” Hierarchical clustering (dendrogram)
  • โ€”joblib โ€” Model persistence

Group 9 | TechCrush AI/ML Programme