Skip to content

Customer segmentation project using RFM analysis to classify customers based on recency, frequency, and monetary value. This notebook cleans transactional data, calculates RFM scores, assigns customer segments, and visualizes behavior patterns to support targeted marketing and retention strategies.

Notifications You must be signed in to change notification settings

awinardi1004/customer-segmentation-RFM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Customer Segmentation using RFM Analysis

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.

Project Overview

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.

Workflow

  1. Import Libraries
    Pandas, NumPy, Matplotlib, Seaborn, datetime
  2. Load Transaction Dataset
    Load raw transactional data into a DataFrame for cleaning and processing.
  3. Data Preparation
  • Convert date columns
  • Remove duplicates
  • Handle missing values
  • Standardize data types
  1. Calculate RFM Metrics
  • Recency: days since last purchase
  • Frequency: number of transactions
  • Monetary: total amount spent
  1. Score RFM Values
    Use quantile-based scoring to assign scores (1–4 or 1–5) for each R, F, and M metric.
  2. Build RFM Segments
    Combine RFM scores to classify customers, e.g.:
  • Champions
  • Loyal Customers
  • Potential Loyalists
  • At Risk
  • Hibernating

Key Insights

  • 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.

Technologies Used

  • Python
  • Pandas
  • NumPy

Contact

Created by Winardi
Linkedin : https://www.linkedin.com/in/winardi-/

About

Customer segmentation project using RFM analysis to classify customers based on recency, frequency, and monetary value. This notebook cleans transactional data, calculates RFM scores, assigns customer segments, and visualizes behavior patterns to support targeted marketing and retention strategies.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published