Session Ready
Exercise

Build features

You are now fully equipped to build recency, frequency, monetary value and other customer level features for your regression model. Feature engineering is the most important step in the machine learning process. In this exercise you will create five customer-level features that you will then use in predicting next month's customer transactions. These features capture highly predictive customer behavior patterns.

The pandas and numpy libraries have been loaded as pd as np respectively. The online_X dataset has been imported for you. The datetime object NOW depicting the snapshot date you will use to calculate recency has been created for you.

Instructions
100 XP
  • Calculate recency by subtracting the current date from the latest InvoiceDate.
  • Calculate frequency by counting the unique number of invoices.
  • Calculate monetary value by summing all spend values.
  • Calculate average and total quantity.