This project performs customer segmentation using the RFM (Recency, Frequency, Monetary) model to understand customer value and behavioral patterns. The analysis transforms raw transaction data into actionable customer groups that can support targeted marketing, retention strategies, and business decision-making.
Customer segmentation is essential for identifying high-value customers and optimizing marketing efforts. Using historical transaction data, this project calculates RFM scores for each customer and classifies them into meaningful segments such as Champions, Loyal Customers, Potential Loyalists, At Risk, and Hibernating.
The entire workflow includes data cleaning, feature engineering, RFM scoring, segment assignment, and visualization.
- Import Libraries
Pandas, NumPy, Matplotlib, Seaborn, datetime - Load Transaction Dataset
Load raw transactional data into a DataFrame for cleaning and processing. - Data Preparation
- Convert date columns
- Remove duplicates
- Handle missing values
- Standardize data types
- Calculate RFM Metrics
- Recency: days since last purchase
- Frequency: number of transactions
- Monetary: total amount spent
- Score RFM Values
Use quantile-based scoring to assign scores (1–4 or 1–5) for each R, F, and M metric. - Build RFM Segments
Combine RFM scores to classify customers, e.g.:
- Champions
- Loyal Customers
- Potential Loyalists
- At Risk
- Hibernating
- High-value customer groups contribute the largest portion of revenue
- Several customer segments show declining activity and require re-engagement.
- RFM segmentation helps prioritize marketing budgets based on customer value.
- Python
- Pandas
- NumPy
Created by Winardi
Linkedin : https://www.linkedin.com/in/winardi-/