I am trying to segment customers based on how recently they visited the store. However, I am also trying to incorporate the frequency with which they visit the store. For example, in a data collected between Jan 2015 and Dec 2017, Customer 1 visited 3 times in Jan 2015 and then once in Dec 2017; Customer 2 visited 4 times in Dec 2017. Although the frequency for both the customers is 4 and their recency is same (both came last in Dec 2017), it is clear that Customer 2 is a more recent customer and must be targeted differently than Customer 1.

I tried dividing the data points into n-tiles but it is giving a very crude measure.

Could you guys suggest something which is more sophisticated than an RFM-type segmentation?


You might try using an exponentially weighed moving average (EWMA) on visits, giving recent months a higher weight than earlier months.

Here are the steps to calculating an EWMA:

  1. sort the data by customer ID and by Month
  2. weight=0.8; //in the equations in wikipedia, weight is called lambda
  3. if (customerID!=lag(customerID) {movingAverage=NVisits} else { movingAverage=movingAverage*weight + (1-weight)*NVisits}

Here's a link to a Wikipedia article on EWMA: https://en.wikipedia.org/wiki/EWMA_chart

Here's screen shot of a data table where I took a weighted average over 6 months. The highlighted rows are the rows you would actually use in your analysis. You can see that the customer who has more visits in recent months has a higher weighted average than the customer who has more visits in past months.

enter image description here

Picking the weight is a bit of an art. It has to be a number between 0 and 1. If it's closer to 1, later months will have more weight. If it's less than 0.5, later months will have less weight.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.