# Feature Engineering a Recency feature

I have a customer scoring problem I'm working on specifically on predicting conversion and coming up with a probability score on conversion (using xgboost classifier atm). There's a feature I want to introduce, but I am having a hard time formulating what the feature definition should be.

Specifically, I know that when an event A happens recently (eg, customer phones our office), that is an indicator that the customer is interested in our product and might convert. So to do this, I created a recency feature that is basically: (today - event date) in days.

The problem is that this does not capture the influence of older customer records. For example, a customer might have called us a year ago (event A triggered) and converted soon thereafter and using that formula, the recency feature will be relatively large. I want the model to learn that low recency values translate to higher probability.

Are there any good ways to engineer the feature to capture this relationship?

• What if you assume that after $X$ days the the call did not result in a conversion, then you could have two fields, one capturing whether the customer converted, and then a second specifying the number of days, which could be $min(\text{last call} - \text{day of conversion}, X)$ Commented May 15 at 14:54
• @nwaldo I tried something similar as a feature and that resulted in overfitting. I think what was happening is say, all of the customers who converts have called us, but not all customers who call will convert. And so the model attributes a super high probability to every customers who calls Commented May 15 at 18:20

I think an exponential decay or RBF feature would map close dates towards 1.0, and distant dates to smaller values (approaching zero in the limit). In particular, consider this formulation:

$$\mathrm{call\_score}=\exp\{-[min(\mathrm{current\_date},~\mathrm{conversion\_date\_if\_available) - \mathrm{call\_date}}]\}$$

We can break it down into the following scenarios which cover all bases:

• If a customer called long ago, and shortly thereafter converted, the feature would be close to 1.

• If a customer called recently, and converted shortly after, the feature would be close to 1.

• These two cases capture: short conversion times score highly
• If a customer called recently, and hasn't converted, their score would still be high.

• We consider them to be at a high likelihood of converting, having called recently despite not yet converting.
• If a customer called long ago, but took a while to convert, their score will be decayed according to how long they took.

• If a customer called long ago, and still hasn't converted, they'd have the lowest score of all.

• These two cases capture: if it has been a while since you've called, and then converted late or not at all, you score low.