Comparing features to reference variables
In the previous recipe, Combining features with mathematical functions, we created new features by applying mathematical or statistical functions, such as the sum or the mean, to a group of variables. Some mathematical operations, however, such as subtraction or division, are performed between features. These operations are useful to derive ratios, such as the debt-to-income ratio:
debt-to-income ratio = total debt / total income
These operations are also useful to compute differences, such as the disposable income:
disposable income = income - total debt
In this recipe, we will learn how to create new features by subtracting or dividing variables with pandas
and feature-engine
.
Note
In the recipe, we will show you how to create features with subtraction and division. We hope that the examples, relating to the financial sector, shed some light on how to use domain knowledge to decide which features to combine and how.