What is RFM Analysis?
RFM Analysis is a technique used to segment people or institutions with similar purchasing behavior based on customers’ past purchasing behavior. It is used to determine marketing strategies, to give pinpoint messages, to understand the target audience for advertisements and promotions. It gives an idea about how many personnel should be allocated to each customer, how much time the marketing team should allocate, and how much investment should be made for which group.
There are 3 basic metrics of RFM technique. Recency, Frequency and Monetary.
Recency (R) : It refers to the time elapsed since the customer’s last purchase date. It makes us think that customers who have shopped more recently use our products, have contacted us recently, and are likely to prefer our company again. Therefore, low Recency, that is, being close to the last purchase date, will result in higher scores.
Frequency (F) : It is the number of purchases by the customer, which can simply be thought as the number of invoices. The more the customer prefers our company, the more we can expect him to continue this behavior in the future.
Monetary (M) : It refers to how much money the customer pays for his purchases. Similar to frequency, the amount of money paid has a positive effect on being in the upper segments in the grouping.
How is RFM applied?
A customer-based scoring is performed on the Recency, Frequency and Monetary metrics.
Considering the behavior of all customers in the same time period, the rank of the customer in these three metrics is determined. For example, while a customer who bought a product 3 days ago gets 5 in the Recency scoring; another customer who made the last purchase 120 days ago may get a score of 1. Generally, 5 different intervals are determined according to the Recency values of all customers. More customized ranges can also be determined according to the company sector or categories.
Similarly, a scoring is done also for Frequency and Monetary. Customers who shop more and spend more get better scores on these metrics.
Let’s do a sample study
For this study, I preferred the data set named Online Retail II. Available at this address: https://archive.ics.uci.edu/ml/datasets/Online+Retail+II
The data set includes the sales of a UK-based online store between 12/2009 and 12/2011.
First observations of the data set:
Since the data preparation is out of our scope, this part is not mentioned.
The products in the invoices are given on separate lines, the product’s unit price (Price) and the quantity of this product the customer buys (Quantity) are stated. Let’s calculate the total amount paid by the customer for this product and add it to the data as TotalPrice.
Total amount paid for the product (Total Price) = Quantity x Price
Let’s calculate the metrics we need to group the data over the customer id:
1. Customer’s Recency:
Today’s date (or a few days after the latest date in the data, if the data is old) - Customer’s last purchase date
2. Customer’s Frequency:
Total number of unique invoices
3. Customer’s Monetary:
The total amount he paid for all his purchases
After that, this grouped data by customer id’s and these metrics are enough for us.
Let’s divide the values in these 3 metrics into 5 segments and make a metric-specific scoring.
In my work, I simply determined the scores with the Qcut function of the Pandas library, I preferred a scoring from 1 to 5.
From now on, the scores are important for us, not the values.
Let’s put these 3 scores together and form our overall RFM Score.
Now we can segment customers through the RFM score.
For example, a score of 555 represents our top-scoring customers who have both made recent purchases and made a large number of purchases in the relevant time period. We can see this group as champions.
Scores starting with 51 refer to new customers with a Recency of 5 and a Frequency of 1, that is, recent purchase with a very low total number of orders.
Scores starting with 15 are customers who used to shop a lot but haven’t made any purchases for a long time.
Scores that start with numbers like 34, 35, 44, 45 can be considered as loyal customers.
Segmentation can be made only through Recency and Frequency, without including the Monetary value, or instead of the Monetary value, interaction metrics such as the number of website visits or the call center calls can be used.
In summary, instead of evaluating all customers one by one, we evaluate those with similar purchasing behaviors together. Marketing strategies, group-specific campaigns can be determined based on this.
1. Veri Bilimi Okulu, Data Science and Machine Learning Bootcamp lecture notes:
4. The pictures are taken from: