After discretization, the intervals of the variable can be treated as a discrete numerical variable, or as categories in a categorical variable. If treated as categorical, we can follow up the discretization by reordering the intervals according to the target value, as we did in the Encoding with integers in an ordered manner recipe in Chapter 3, Encoding Categorical Variables, to create a monotonic relationship between the intervals and the target. In this recipe, we will combine these two feature engineering techniques using Feature-engine and the Boston House Prices dataset from scikit-learn.
Performing discretization followed by categorical encoding
How to do it...
To perform equal-frequency discretization...