![[16.png|480]]
Customer segmentation is one of the most common unsupervised learning applications in finance and marketing. Rather than predicting an outcome, the objective is to discover naturally occurring customer groups that share similar financial behaviors.
In this project, I built an end-to-end customer segmentation pipeline using **KMeans clustering** on a synthetic credit card customer dataset containing **50,000 customers**. The project focuses on feature engineering, data preprocessing, cluster evaluation, and business interpretation to identify actionable customer personas.
# Business Objective
Financial institutions manage millions of customers with vastly different spending habits, repayment behaviors, and product usage.
Instead of treating every customer equally, banks can use customer segmentation to:
- personalize marketing campaigns
- recommend appropriate credit card products
- identify high-value customers
- improve customer retention
- optimize loyalty programs
- support credit risk management
The goal of this project is to discover meaningful customer segments using unsupervised machine learning.
# Dataset
The dataset contains **50,000 credit card customers** with demographic, financial, spending, and behavioral variables.
Examples include:
### Customer information
- Age
- Gender
- Occupation
- Card Type
- Annual Income
### Credit information
- Credit Limit
- Credit Utilization
- Outstanding Balance
- Statement Balance
- Payment Amount
- Payment Ratio
### Spending behavior
- Monthly Spending
- Monthly Transactions
- Average Transaction Value
- Online Shopping
- Grocery
- Dining
- Fuel
- Travel
- Entertainment
- Utilities
### Customer engagement
- Mobile App Login
- Reward Points
- Reward Redemption
- International Transactions
- EMI Usage
# Project Workflow
The project followed a complete end-to-end clustering workflow.
## 1. Exploratory Data Analysis (EDA)
The first step was to understand the data distribution.
I explored:
- missing values
- descriptive statistics
- feature distributions
- skewness
- outliers
- correlation matrix
- VIF (Variance Inflation Factor)
The EDA revealed that many financial variables were **highly right-skewed** with significant outliers, including:
- Annual Income
- Monthly Spending
- Credit Limit
- Outstanding Balance
- Cash Advance
These distributions required appropriate preprocessing before clustering.
## 2. Data Preprocessing Pipeline
Rather than manually transforming variables, I built a reusable **Scikit-learn preprocessing pipeline**.
Different preprocessing techniques were automatically applied depending on the feature characteristics.
# Feature Engineering
Raw transaction data often fails to capture customer behavior effectively.
To better describe financial habits, I engineered several behavioral ratio features.
Examples include:
- Spending-to-income ratio
- Balance-to-income ratio
- Spend per transaction
- Cash advance to spending ratio
- Reward redemption rate
- International transaction ratio
- Spending category shares
- Transactions per mobile app login
These engineered variables provide a more behavior-oriented representation than raw spending amounts alone.
# Feature Selection
Before clustering, I examined:
- Correlation matrix
- Variance Inflation Factor (VIF)
Highly redundant variables were removed to reduce multicollinearity while preserving customer behavior information.
# Dimensionality Reduction
I also evaluated PCA before clustering.
Although PCA reduced dimensionality, it produced only a marginal improvement in clustering quality.
Since interpretability is essential for customer segmentation, I retained the original engineered features.
# Clustering Models
Two clustering algorithms were evaluated:
- KMeans
- Gaussian Mixture Models (GMM)
Each model was evaluated using multiple values of **k**.
Evaluation metrics included:
- Silhouette Score
- Calinski-Harabasz Index
- Davies-Bouldin Index
# Model Selection
The highest Silhouette Score occurred with **KMeans (k = 2)**.
However, a two-cluster solution mainly separated customers into broad high-value and low-value groups, providing limited business value.
Instead, I selected the **four-cluster KMeans model**, which produced substantially richer customer personas while maintaining good clustering quality.![[Screenshot 2026-08-16 at 2.49.12 PM.png|473]]
Compared with the original feature set, the engineered behavioral features significantly improved the quality of the **four-cluster** solution.
# Customer Segments
![[Pasted image 20260816153522.png|556]]
## Cluster 0 — Elite Premium Customers (7%)
### Characteristics
- Highest annual income
- Highest credit limits
- Extremely high monthly spending (approximately **70% of monthly income**)
- Largest transaction values and high transaction frequency
- Highest outstanding balances
- Most international transactions
- Highest EMI usage, indicating greater use of installment financing
- Moderate credit utilization despite very large balances
These customers represent the bank's highest-value premium clients. They actively use their credit cards across many spending categories while maintaining relatively healthy repayment behavior.
### Business Opportunities
- Premium and invitation-only credit cards
- Luxury travel and concierge benefits
- Wealth management and investment products
- Personalized relationship management
- Exclusive loyalty and retention programs
## Cluster 1 — Everyday Mass-Market Users (39%)
### Characteristics
- Lowest annual income
- Lowest monthly spending (approximately **49% of monthly income**)
- Lowest credit limits
- Lowest transaction frequency
- Very few international transactions
- Lowest EMI usage
- Low credit utilization and consistent repayment behavior
These customers primarily use their credit cards for everyday purchases and appear financially conservative with relatively light card usage.
### Business Opportunities
- Cashback and grocery rewards
- Dining and fuel promotions
- Credit limit increase campaigns
- Digital engagement initiatives
- Cross-selling entry-level financial products
## Cluster 2 — Cash Advance Users (13%)
### Characteristics
- High annual income
- Moderate-to-high monthly spending
- Highest cash advance usage relative to spending
- Moderate transaction frequency
- Active reward program participation
- Moderate international spending
These customers frequently rely on cash advances in addition to regular card spending, suggesting that they use their credit cards both for purchases and short-term liquidity.
### Business Opportunities
- Personal loan or line-of-credit offers as alternatives to cash advances
- Premium travel and rewards programs
- Credit monitoring and financial wellness recommendations
- Personalized borrowing products---
## Cluster 3 — Affluent Active Spenders (41%)
### Characteristics
- High annual income
- High monthly spending
- Highest transaction frequency
- Very low cash advance usage
- High EMI usage
- Healthy repayment behavior
- Strong mobile app engagement
These customers are highly engaged card users who make frequent purchases while rarely relying on cash advances, indicating that they primarily use their credit cards as a payment tool rather than a source of short-term borrowing.
### Business Opportunities
- Premium card upgrades
- Investment and wealth management products
- Personalized rewards and merchant offers
- Subscription and lifestyle partnerships
- Long-term customer loyalty programs
# Feature Importance Analysis
To understand what differentiates the customer segments, I evaluated feature importance using two complementary approaches:
- ANOVA F-test
- CatBoost feature importance
Both methods produced highly consistent rankings, increasing confidence that the discovered segments represent meaningful behavioral differences rather than random variation.
## Key Findings
### Customer behavior matters more than demographics
Age and card tenure contributed very little to segmentation.
Instead, customer behavior dominated the clustering.
### The most important features were
- Spend per transaction
- Cash advance to spending ratio
- Annual income
- Mobile app login frequency
- EMI count
- Monthly transaction count
- International transaction ratio
- Spending-to-income ratio
- Balance-to-income ratio
These variables consistently ranked among the most important features in both ANOVA and CatBoost analyses.
### Feature engineering significantly improved interpretability
One of the most interesting findings is that engineered behavioral features consistently outperformed raw transaction variables.
Instead of simply measuring how much customers spend, the most useful variables described **how customers use their credit cards**.
Examples include:
- spending relative to income
- borrowing relative to spending
- transaction intensity
- international purchasing behavior
This highlights the importance of thoughtful feature engineering in unsupervised learning.
### Spending composition contributed surprisingly little
Variables describing **where customers spend money** (grocery, travel, dining, fuel, entertainment) had relatively low importance.
Instead, the clustering was driven primarily by:
- financial capacity
- spending intensity
- repayment behavior
- credit usage
- customer engagement
This suggests that spending behavior is more informative than spending category preferences for identifying meaningful customer segments.
# Business Insights
The final segmentation identifies four distinct customer personas with different financial behaviors and business value.
These segments can support a wide range of business applications, including:
- Personalized marketing campaigns
- Loyalty program optimization
- Credit limit management
- Customer lifetime value strategies
- Premium product recommendations
- Customer retention initiatives
- Credit risk monitoring
Rather than applying the same strategy to every customer, financial institutions can tailor products and marketing to each segment based on its behavioral profile.
# Conclusion
This project demonstrates a complete customer segmentation workflow, from exploratory data analysis and preprocessing to clustering, feature engineering, model evaluation, and business interpretation.
Several important lessons emerged:
- Behavioral features are substantially more informative than demographic variables.
- Engineered ratio features capture customer financial habits more effectively than raw transaction amounts.
- Combining statistical validation with machine learning feature importance provides a robust framework for explaining unsupervised models.
Overall, this project illustrates how modern data science techniques can transform raw financial transaction data into meaningful customer insights that support personalized marketing, product strategy, and long-term customer relationship management.