#### Overview of this book

Feature engineering, the process of transforming variables and creating features, albeit time-consuming, ensures that your machine learning models perform seamlessly. This second edition of Python Feature Engineering Cookbook will take the struggle out of feature engineering by showing you how to use open source Python libraries to accelerate the process via a plethora of practical, hands-on recipes. This updated edition begins by addressing fundamental data challenges such as missing data and categorical values, before moving on to strategies for dealing with skewed distributions and outliers. The concluding chapters show you how to develop new features from various types of data, including text, time series, and relational databases. With the help of numerous open source Python libraries, you'll learn how to implement each feature engineering method in a performant, reproducible, and elegant manner. By the end of this Python book, you will have the tools and expertise needed to confidently build end-to-end and reproducible feature engineering pipelines that can be deployed into production.
Preface
Chapter 3: Transforming Numerical Variables
Chapter 4: Performing Variable Discretization
Chapter 5: Working with Outliers
Chapter 6: Extracting Features from Date and Time Variables
Chapter 7: Performing Feature Scaling
Chapter 8: Creating New Features
Chapter 9: Extracting Features from Relational Data with Featuretools
Chapter 10: Creating Features from a Time Series with tsfresh
Chapter 11: Extracting Features from Text Variables
Index
Other Books You May Enjoy

# Performing multivariate imputation by chained equations

Multivariate imputation methods, as opposed to univariate imputation, use multiple variables to estimate the missing values. In other words, the missing values of a variable are modeled based on the other variables in the dataset. Multivariate Imputation by Chained Equations (MICE) models each variable with missing values as a function of the remaining variables and uses that estimate for imputation.

The following steps are required to perform MICE:

1. A simple univariate imputation is performed for every variable with missing data, for example, median imputation.
2. One specific variable is selected, say, `var_1`, and the missing values are set back to missing.
3. A model is trained to predict `var_1` using the remaining variables as input features.
4. The missing values of `var_1` are replaced with the new estimates.
5. Steps 2 to 4 are repeated for each of the remaining variables.

Once all the variables have been...