How it works...
In this recipe, we applied power transformations using NumPy, scikit-learn, and Feature-engine while using the Boston House Prices dataset from scikit-learn.
To apply exponential functions with NumPy, we created a copy of the original dataframe with pandas copy(). Next, we used the power() method on a slice of the dataset with the variables to transform and captured the transformed variables in the new dataframe. This procedure returned a pandas dataframe with the original variables, and LSTAT, NOX, DIS, and RM were transformed with a power of 0.3.
To apply an exponential transformation with scikit-learn, we used FunctionTransformer(), which applies a user-defined function. We started the transformer with np.power() within ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access