The Box-Cox transformation belongs to the power family of functions and is defined by if X > 0 or log(X) if X = 0, where X is the variable and λ is the transformation parameter. In the Box-Cox transformation, several values of λ are considered and the λ that returns the best transformation is selected. In this recipe, we will perform Box-Cox transformation using SciPy, scikit-learn, and Feature-engine.
The Box-Cox transformation can only be used on positive variables. If your variables have negative values, try the Yeo-Johnson transformation, which is described in the next recipe, Performing Yeo-Johnson transformation on numerical variables.