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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.