Customer segmentation using K-Means Clustering to divide mall customers into distinct groups based on their demographics and spending behavior. This analysis helps businesses target marketing campaigns more effectively.
- 📈 K-Means Clustering — Segments customers into optimal groups using the Elbow Method
- 📊 Multi-Parameter Analysis — Clustering on age, annual income, and spending score
- 🎨 3D Visualization — Interactive 3D scatter plot showing all 5 customer segments
- 📉 Elbow Method — Automatic optimal cluster detection
- 📓 Jupyter Notebook — Step-by-step analysis with explanations
Using the Mall Customers Dataset from Kaggle.
| Feature | Description |
|---|---|
CustomerID |
Unique customer identifier |
Gender |
Male / Female |
Age |
Customer age |
Annual Income (k$) |
Annual income in thousands |
Spending Score (1-100) |
Mall-assigned score based on spending behavior |
The analysis identifies 5 distinct customer segments using K-Means on Age, Annual Income, and Spending Score:
| Cluster | Profile | Marketing Strategy |
|---|---|---|
| 1 | High Income, High Spending | Premium loyalty programs |
| 2 | High Income, Low Spending | Targeted engagement campaigns |
| 3 | Low Income, High Spending | Value deals & installment plans |
| 4 | Low Income, Low Spending | Budget-friendly promotions |
| 5 | Average across all metrics | General marketing |
| Component | Technology |
|---|---|
| Language | Python 3.8+ |
| ML Algorithm | K-Means Clustering (Scikit-learn) |
| Visualization | Matplotlib, Pyplot (3D) |
| Data Processing | Pandas, NumPy |
| Notebook | Jupyter Notebook |
- Python 3.8+ installed
- Jupyter Notebook or JupyterLab
-
Clone the repository
git clone https://github.com/sujitha-kotyada/Customer-Segmentation-using-ML.git cd Customer-Segmentation-using-ML -
Install dependencies
pip install pandas numpy scikit-learn matplotlib jupyter
-
Run the notebook
jupyter notebook "Customer Segmentation from Marketing Data.ipynb"
python extract_and_run.py # Extracts code from notebook
python run_notebook.py # Runs the extracted scriptCustomer-Segmentation-using-ML/
├── Customer Segmentation from Marketing Data.ipynb # Main analysis notebook
├── Mall_Customers.csv # Dataset
├── extract_and_run.py # Script to extract notebook code
├── run_notebook.py # Auto-generated runnable script
├── 3d_plot_5_clusters.png # 3D cluster visualization
├── output_figure_*.png # Generated analysis plots
├── Steps.jpeg # Methodology diagram
└── README.md
- Data Loading — Load and explore the Mall Customers dataset
- Feature Selection — Select relevant features for clustering
- Elbow Method — Determine optimal number of clusters (k)
- K-Means Clustering — Apply K-Means with optimal k values
- Visualization — 2D and 3D scatter plots of customer segments
- Interpretation — Profile each cluster for business insights
This project is open source and available under the MIT License.
Sujitha Kotyada — @sujitha-kotyada