Project re-upload notice (Jan 2026)
I got locked out of the original GitHub account that hosted this project. This repository is intended to be re-uploaded and maintained under my new GitHub account.
New canonical repo : https://github.com/agilap/Customer-Segmentation-Model
Reupload notice (2026-01-22): This project has been reuploaded to a new GitHub repository. Update the clone URL in the Getting Started section to match the new location.
Customer segmentation is a powerful way for businesses to understand and group their customers based on behavior. This project performs RFM Analysis (Recency, Frequency, Monetary) and uses K-Means Clustering to discover unique customer segments from retail transaction data.
- File:
Online Retail.xlsx - Description: Real-world online retail dataset containing transactions from 2010–2011.
- Key Fields:
CustomerID,InvoiceNo,InvoiceDate,Quantity,UnitPrice
- Removed rows with missing
CustomerID - Filtered out transactions with negative
QuantityorUnitPrice - Created a new column:
TotalPrice = Quantity × UnitPrice
- Recency: Days since last purchase (from the most recent date)
- Frequency: Number of unique purchases (
InvoiceNo) - Monetary: Total spending per customer
- Optimal number of clusters (
k) is chosen based on lowest inertia and silhouette evaluation.
- Created a reusable scikit-learn pipeline with:
StandardScalerKMeans
- Trained on the RFM features and predicted segments across the dataset.
customer_segments.csv:- Contains:
CustomerID, RFM metrics, assigned cluster
- Contains:
- Use these segments to identify:
- VIP customers
- At-risk/dormant users
- Frequent but low spenders
- New or seasonal shoppers
- Python 3
pandas,numpy,matplotlib,seaborn,yellowbrickscikit-learnfor clustering and pipelinejupyterfor interactive development
- Clone the repo
git clone https://github.com/agilap/customer-segmentation.git cd customer-segmentation
2. Install dependencies
```bash
pip install -r requirements.txt
-
Place dataset in the project root.
-
Run the script to generate visualizations and the final csv.
python main.py



