Session Ready
Exercise

Recency feature

A recency feature says how recent a certain event has happened in the past. The more recent an event has occurred, the closer its recency will be to 1. If a new and previously unseen case occurs, its recency will be 0. Such features helps detecting anomalous behavior. In the video, you learned how to create a recency feature based on a categorical feature. You're provided with the dataset trans containing transactions made by Alice and Bob. You're going to create a recency feature called rec_channel based on the column channel_cd.

The zoo and dplyr packages are loaded for you. The frequency feature freq_channel from the previous exercise was added to the dataset trans. trans$timestamp are converted to hourly format, and gamma has been set for you to -log(0.01)/90.

Instructions 1/4
undefined XP
  • 1
  • 2
  • 3
  • 4
  • Write the first part of a function recency_fun() which takes t, gamma, channel_cd and freq_channel as inputs, and computes the recency. If a channel has never been used, it should return 0.