Home Knowledge Base Polynomial Features

Polynomial Features is a feature engineering technique that creates new features by computing polynomial terms (squares, cubes) and interaction terms (products of features) from existing variables — enabling linear models to learn non-linear decision boundaries by expanding the feature space from $[a, b]$ to $[1, a, b, a^2, ab, b^2]$, where the interaction term $ab$ can capture relationships that neither $a$ nor $b$ reveals alone (house price depends on length × width = area, not length or width independently).

What Are Polynomial Features?

Polynomial Expansion Example

Starting with features $a$ and $b$:

DegreeGenerated FeaturesCount
1$a, b$2
2$a, b, a^2, ab, b^2$5
3$a, b, a^2, ab, b^2, a^3, a^2b, ab^2, b^3$9
dAll combinations up to degree dRapidly grows

Interaction Terms: The Most Valuable Component

FeaturesInteractionReal-World Meaning
Length, WidthLength × WidthArea (determines house price)
Education, ExperienceEducation × ExperienceCombined effect on salary
Temperature, HumidityTemp × HumidityFeels-like / heat index
Ad Spend, SeasonSpend × SeasonHoliday ad effectiveness

Python Implementation

from sklearn.preprocessing import PolynomialFeatures

poly = PolynomialFeatures(degree=2, include_bias=False,
                          interaction_only=False)
X_poly = poly.fit_transform(X)  # [a, b] -> [a, b, a², ab, b²]

# Interaction only (no squared terms)
inter = PolynomialFeatures(degree=2, interaction_only=True,
                           include_bias=False)
X_inter = inter.fit_transform(X)  # [a, b] -> [a, b, ab]

The Dimensionality Explosion Problem

Original FeaturesDegreeNew FeaturesGrowth
2252.5×
102656.5×
5021,32526.5×
10025,15051.5×
1003176,8501,768×

Solutions: Use interaction_only=True (skip squared terms), apply feature selection after expansion, or use regularization (Ridge/Lasso) to zero out unimportant terms.

When to Use Polynomial Features

UseDon't Use
Linear models with non-linear patternsTree-based models (they capture interactions natively)
Known feature interactions (area = L × W)Very high-dimensional data (dimensionality explodes)
Small number of features (<20)When you already have hundreds of features
Paired with regularization (Ridge/Lasso)Without regularization (severe overfitting)

Polynomial Features is the feature engineering technique that gives linear models non-linear power — creating squared and interaction terms that enable linear regression and logistic regression to fit curved decision boundaries, with the critical caveat that dimensionality grows combinatorially and regularization is essential to prevent overfitting on the expanded feature set.

polynomialinteractionfeature

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.