Customer Segmentation

🧠 Customer Segmentation
Project Type: Unsupervised Learning | Industry Focus: Retail / E-commerce / B2C | Tools Used: Python, Pandas, Scikit-learn, Matplotlib, Seaborn
🔍 Project Overview
Applied clustering techniques to segment customers based on purchasing behavior, demographics, and engagement patterns. This project helps businesses personalize marketing campaigns, improve customer retention, and identify high-value clients.
🎯 Objectives
- Group customers into distinct segments based on behavior and value
- Enable targeted promotions, upselling strategies, and personalized experiences
- Provide data-driven insights to enhance customer lifetime value (CLV)
🧩 Dataset
- Source: E-commerce customer dataset (Kaggle / simulated CRM data)
- Features: Age, Gender, Annual Income, Spending Score, Purchase Frequency, Tenure, etc.
🛠️ Techniques & Methodology
- Data preprocessing: scaling, outlier removal, and feature selection
- Used K-Means clustering with the Elbow Method and Silhouette Score for optimal K
- Visualized clusters using PCA and 2D scatter plots
- Profiled each cluster based on income, spending, and engagement
🚀 Key Results
- Identified 4 key customer segments: High Spenders, Budget Shoppers, Infrequent Buyers, and Loyal Customers
- Enabled precision targeting for promotions and loyalty rewards
- Produced visual cluster maps for marketing and sales alignment
💼 Business Impact
This segmentation model allows companies to tailor messaging, pricing, and product offerings to specific customer groups, leading to increased conversion rates, better customer retention, and maximized return on marketing investment (ROMI).
💼 Business Impact
This segmentation model allows companies to tailor messaging, pricing, and product offerings to specific customer groups, leading to increased conversion rates, better customer retention, and maximized return on marketing investment (ROMI)
Code Snippet
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.preprocessing import StandardScaler
from scipy.cluster.hierarchy import dendrogram, linkage
from sklearn.cluster import KMeans
from sklearn.decomposition import PCA
import missingno as msno
from IPython.display import display
from sklearn.preprocessing import OrdinalEncoder
sns.set()
import warnings
warnings.filterwarnings('ignore')
# Load the dataset
train=pd.read_csv('../input/customer-segmentation/train.csv')
train[['ID', 'Gender', 'Ever_Married', 'Age', 'Graduated', 'Profession',
'Work_Experience', 'Spending_Score', 'Family_Size']]
# Preprocessing
num_trans=Pipeline(steps=[('imputer',SimpleImputer()),('scaler',StandardScaler())])
# Categorical tranformation
encode=OrdinalEncoder(dtype=object)
customer_encode=pd.DataFrame(encode.fit_transform(customer),columns=customer.columns)
customer_encode.head(3)
stand=StandardScaler()
stand=stand.fit_transform(customer_encode)
stand
# Initialize and train the model
wcss=[]
for i in range(1,11):
kmean=KMeans(n_clusters=i).fit(stand)
wcss.append(kmean.inertia_)
print(wcss)
# Evaluate the model
y_pred=model.predict(x_test)
pd.DataFrame({'r2_score':[r2_score(y_test,y_pred).round(3)*100],'mean_squared_error':[mean_squared_error(y_test,y_pred)],'mean_absolute_error':[mean_absolute_error(y_test,y_pred)]})



















