The reciprocal function, defined as 1/x, is a strong transformation with a very drastic effect on the variable distribution. It isn't defined for the value 0, but it can be applied to negative numbers. In this recipe, we will implement the reciprocal transformation using NumPy, scikit-learn, and Feature-engine and compare its effect with a diagnostic function.
Transforming variables with the reciprocal function
How to do it...
Let's begin by importing the libraries and getting the dataset ready:
- Import the required Python libraries, methods, and classes:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import scipy.stats as stats
from sklearn.datasets import load_boston
from sklearn.preprocessing...