How it works...
In this recipe, we applied the reciprocal transformation to a group of variables using NumPy, scikit-learn, and Feature-engine. To determine the effect of the transformation, we created a diagnostic function to plot a histogram next to a Q-Q plot for a given variable. For more details on step 1 to step 3, check out the Transforming variables with the logarithm recipe, earlier in this chapter.
Utilizing the diagnostic plot function, we plotted the histogram and Q-Q plot of the DIS variable and observed that it wasn't normally distributed: most of its values were at the left of the histogram and they deviated from the 45-degree line at both ends of the distribution in the Q-Q plot.
To apply the reciprocal transformation with ...
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