Getting ready

Polynomial expansion serves to automate the creation of new features, to capture feature interaction, and to capture potential non-linear relationships between the original variables and the target. The user determines which features to combine and which polynomial degree to use.

Keep in mind that high polynomial degrees or a large number of features to combine will return an enormous number of new features.

The PolynomialFeatures() transformer from scikit-learn creates all polynomial combinations of the features with a degree less than or equal to the specified degree, automatically. To follow up easily with the recipe, let's first understand the output of the PolynomialFeatures() transformer from scikit-learn, when used with ...

Get Python Feature Engineering Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.