Combining features with mathematical functions
New features can be created by combining existing variables with mathematical and statistical functions. At the beginning of this chapter, we mentioned that we can calculate the total debt by summing up the debt across individual financial products, as follows:
Total debt = car loan debt + credit card debt + mortgage debt
We can also derive other insightful features using alternative statistical operations. For example, we can determine the maximum debt of a customer across financial products or the average time users have spent on a web page:
maximum debt = max(car loan balance, credit card balance, mortgage balance)
average time on page = mean(time spent user 1, time spent user 2, time spent user 3)
We can, in principle, use any mathematical or statistical operation to create new features, such as the product, mean, standard deviation, or maximum or minimum values, to name a few. In this recipe, we will implement these...