Performs RFM (Recency, Frequency, Monetary) analysis on customer transaction data to segment customers based on their purchase behavior. Creates powerful customer segmentation for targeted marketing campaigns and customer relationship management.
When to Use
Segment customers based on purchasing behavior
Identify high-value customers and at-risk customers
Prioritize marketing efforts and resource allocation
Create targeted marketing campaigns
Understand customer lifecycle stages
Analyze customer retention and churn potential
Develop loyalty programs based on behavior patterns
How It Works
Takes transaction data with customer IDs, transaction dates, and monetary values
Calculates three key metrics for each customer:
Recency: How recently the customer made a purchase (in days)
Frequency: How often the customer makes purchases (count of transactions)
Monetary: How much money the customer spends (total or average value)
Scores each customer on each dimension using the selected scoring method
Returns a comprehensive customer-level dataset with all RFM metrics and scores
Preserves the original customer identifiers for easy integration with other data
Parameters
Required
idCol (string) - Column name containing customer identifiers (default: customerID)
dateCol (string) - Column name containing transaction dates (default: transactionDate)
amtCol (string) - Column name containing transaction amounts (default: amount)
Optional
type (string) - Scoring method to use (default: quintile):
quintile - 5 equal groups (1-5 scoring)
decile - 10 equal groups (1-10 scoring)
quartile - 4 equal groups (1-4 scoring)
custom - Custom number of groups specified by k parameter
k (integer) - Number of groups for custom scoring (only used when type is custom)
evenBinCounts (string) - Whether to ensure equal number of customers in each bin (default: false)
Input Requirements
Transaction-level data (multiple transactions per customer)
Valid customer identifier column
Valid transaction date column (must be in a format that can be parsed as a date)
Valid transaction amount column (must be numeric)
Output Columns
Original customer identifier (preserved from input)
recentDate - Most recent transaction date for the customer
recency - Days since most recent purchase
freq - Total number of transactions for the customer
monetary - Total monetary value of all transactions for the customer
rScore - Recency score (higher = more recent purchase)
fScore - Frequency score (higher = more frequent purchases)