This project analyzes customer transaction data from an online retail company to understand purchasing behavior, identify valuable customer segments, and predict customers who are likely to stop buying from the business.
Using Exploratory Data Analysis (EDA), RFM Segmentation, and Machine Learning, the project provides actionable business insights that help improve customer retention, increase revenue, and strengthen long-term customer relationships.
Customer retention is one of the biggest challenges in the retail industry. Although businesses collect large volumes of customer transaction data, they often struggle to identify customers who are likely to churn before they stop purchasing.
Without early identification, businesses lose valuable customers, resulting in reduced revenue and increased customer acquisition costs.
The project uses the Online Retail Transaction Dataset, which contains:
- Invoice Number
- Product Description
- Quantity Purchased
- Unit Price
- Purchase Date
- Customer ID
- Customer Country
The goal was to analyze customer purchasing behavior and develop a predictive model that identifies customers at risk of churn.
The objectives of this project were to:
- Perform Exploratory Data Analysis (EDA) to understand customer purchasing behavior.
- Identify revenue patterns and seasonal sales trends.
- Segment customers using RFM Analysis.
- Build predictive machine learning models for customer churn prediction.
- Evaluate model performance using classification metrics.
- Generate business recommendations to improve customer retention.
- Cleaned missing and invalid transaction records.
- Converted transaction dates into datetime format.
- Calculated Total Revenue.
- Engineered customer-level features.
- Prepared RFM metrics.
Performed detailed analysis on:
- Revenue Distribution
- Monthly Revenue Trends
- Geographic Sales Distribution
- Customer Purchase Frequency
- Customer Revenue Contribution
- Customer Segmentation
A relatively small percentage of customers generated the majority of total revenue.
- Prioritize high-value customer retention.
- Introduce loyalty rewards.
- Offer exclusive promotions.
- Personalize customer experiences.
Monthly revenue fluctuated significantly, with certain months generating considerably higher sales.
- Schedule marketing campaigns during low-performing months.
- Optimize inventory planning.
- Improve promotional timing.
Only a few countries contributed the majority of total revenue.
- Increase investment in top-performing regions.
- Explore growth opportunities in underperforming markets.
Most customers made only a few purchases, while a smaller group purchased frequently.
- Encourage repeat purchases.
- Implement customer loyalty programs.
- Recommend personalized products.
Customers were segmented into:
- π Champions
- β€οΈ Loyal Customers
β οΈ At Risk Customers- β Lost Customers
Each customer segment requires different marketing strategies.
Examples include:
- Rewards for Champions
- Loyalty benefits for Loyal Customers
- Re-engagement campaigns for At Risk Customers
- Win-back offers for Lost Customers
Two supervised machine learning models were developed for customer churn prediction.
- Logistic Regression
- Random Forest Classifier
Dataset Split
- Training Data: 80%
- Testing Data: 20%
The models were evaluated using:
- Accuracy
- Precision
- Recall
- F1 Score
- ROC-AUC Score
Special emphasis was placed on F1 Score and ROC-AUC because these metrics provide a balanced evaluation for identifying churned customers while minimizing false predictions.
Among the two models,
It provided:
- Higher Accuracy
- Better Precision
- Higher Recall
- Improved F1 Score
- Better ROC-AUC Score
The model successfully identified customers who are most likely to churn, enabling businesses to take proactive retention actions.
Customers predicted to be at risk of churn should receive:
- Personalized Emails
- Discount Coupons
- Reminder Notifications
- Re-engagement Campaigns
Reward high-value customers with:
- Exclusive Deals
- Loyalty Rewards
- Early Product Access
- VIP Membership Benefits
Use purchasing behavior insights to:
- Recommend Products
- Bundle Frequently Purchased Items
- Improve Cross-selling
- Increase Average Order Value
This project demonstrates how combining customer analytics with predictive machine learning enables organizations to:
- Improve customer retention
- Increase customer lifetime value
- Reduce churn
- Enhance marketing effectiveness
- Support data-driven business decisions
- Increase long-term revenue
Programming Language
- R
Libraries
- dplyr
- tidyr
- ggplot2
- caret
- randomForest
- e1071
- corrplot
Machine Learning
- Logistic Regression
- Random Forest
IDE
- RStudio
Business Problem
β
βΌ
Data Collection
β
βΌ
Data Cleaning
β
βΌ
Feature Engineering
β
βΌ
Exploratory Data Analysis
β
βΌ
RFM Analysis
β
βΌ
Machine Learning
(Logistic Regression & Random Forest)
β
βΌ
Model Evaluation
β
βΌ
Business Insights
β
βΌ
Business Recommendations
- Business Analytics
- Customer Analytics
- Exploratory Data Analysis
- Customer Segmentation
- RFM Analysis
- Machine Learning
- Predictive Analytics
- Customer Churn Prediction
- Data Visualization
- Business Intelligence
- Statistical Analysis
- Customer Retention Strategy
Customer-Churn-Prediction/
β
βββ data/
β βββ Online Retail Dataset
β
βββ notebooks/
β βββ Customer_Churn_Prediction.ipynb
β
βββ outputs/
β βββ EDA Charts
β βββ RFM Analysis
β βββ Model Evaluation
β βββ Business Insights
β
βββ README.md
β
βββ requirements.txt
- Deploy the model using Streamlit or Shiny.
- Create an interactive Power BI Dashboard.
- Build real-time customer churn prediction.
- Integrate automated customer recommendation systems.
- Improve model performance using XGBoost and LightGBM.
Harendra
MBA (Business Analytics)
π Data Analytics | Business Analytics | Machine Learning | Business Intelligence
If you found this project helpful, please consider giving this repository a β Star.
It helps others discover the project and motivates future improvements.