This project applies machine learning and data analysis techniques to segment customers based on their purchasing behavior, demographics, or spending patterns. Customer segmentation helps businesses understand their audience better and make data-driven marketing or product decisions.
Customer segmentation is a key part of business analytics and marketing strategy. In this project, unsupervised learning (mainly K-Means clustering) is used to identify distinct groups of customers from the dataset.
The project workflow includes:
- Data cleaning and preprocessing
- Exploratory Data Analysis (EDA) and visualization
- Feature scaling and dimensionality reduction (if required)
- Applying clustering algorithms such as K-Means or Hierarchical Clustering
- Interpreting and visualizing customer segments
- Clean and preprocess raw customer data
- Analyze and visualize spending and behavioral patterns
- Automatically group customers with similar traits
- Visualize clusters using 2D/3D plots
- Generate actionable insights for business decision-making
- Python 3.x
- Pandas โ data manipulation
- NumPy โ numerical computations
- Matplotlib / Seaborn โ data visualization
- Scikit-learn โ clustering algorithms, scaling, and PCA
- Jupyter Notebook โ interactive exploration
You can use any customer dataset such as:
- Mall Customer Segmentation Data from Kaggle
- Or any dataset containing fields like:
CustomerIDAgeGenderAnnual IncomeSpending Score
Make sure your data is in CSV format and stored in the data/ folder.
Example:
data/
โโโ Mall_Customers.csv
Customer-segmentation-and-analysis/
โ
โโโ customer_segmentation.ipynb # Main Jupyter notebook
โโโ data/ # Dataset folder
โ โโโ Mall_Customers.csv
โโโ requirements.txt # Dependencies
โโโ README.md # Project documentation
-
Clone the repository:
git clone https://github.com/Username1234jj/Customer-segmentation-and-analysis.git cd Customer-segmentation-and-analysis -
Install dependencies:
pip install -r requirements.txt
-
Place your dataset (
Mall_Customers.csv) in thedata/folder. -
Open the notebook:
jupyter notebook customer_segmentation.ipynb
- Load and explore the dataset.
- Handle missing or inconsistent data.
- Perform EDA to understand variable distributions and relationships.
- Apply feature scaling (StandardScaler or MinMaxScaler).
- Use K-Means clustering to segment customers.
- Determine the optimal number of clusters using the Elbow Method or Silhouette Score.
- Visualize results using scatter plots or PCA.
- Interpret each segment (e.g., high spenders, budget customers, young professionals).
Number of clusters chosen: 5
Cluster Summary:
1 - Young, high spenders
2 - Older, low spenders
3 - Middle-aged, moderate income and spending
...
Visuals include:
- Pair plots of customer groups
- Cluster distribution charts
- Spending vs. income visualizations
- Integrate Hierarchical Clustering or DBSCAN
- Automate insight generation from clusters
- Build a dashboard (Streamlit/Plotly Dash) for interactive analysis
- Connect to a live business database for real-time segmentation
- Kaggle for the Mall Customer Segmentation dataset
- Scikit-learn documentation for clustering references
- Open-source contributors and tutorials that inspired this analysis
This project is released under the MIT License โ free to use and modify for educational and research purposes.