January 2020
Beginner to intermediate
372 pages
10h
English
We can also implement one-hot encoding with Feature-engine. Feature-engine has multiple advantages: first, it allows us to select the variables to encode directly in the transformer. Second, it returns a pandas dataframe with clear variable names, and third, it preserves the information learned from the train set, therefore returning the same number of columns in both train and test sets. With that, Feature-engine overcomes the limitations of pandas' get_dummies() method and scikit-learn's OneHotEncoder() class.
To perform one-hot encoding with Feature-engine, we import pandas, then load and divide the data into train and test as we did in step 1 to step 3 of the main recipe. Next, follow these steps:
Read now
Unlock full access