Feature engineering and preprocessing · insight-0119
Cap polynomial expansion degree and regularize, because generated features grow combinatorially
- Evidence type
- practitioner heuristic
- Difficulty
- medium
- Roles
- Data scientist, ML engineer
- Industries
- manufacturing, energy
Summary: situation, action, reason, boundary
Situation
You apply PolynomialFeatures of degree 3 or more to dozens of inputs to capture nonlinearity.
Action
Prefer interaction_only=True or degree 2 on a few chosen inputs, use splines for single-feature curvature, and pair the expansion with a tuned ridge or elastic-net penalty.
Reason
The number of terms grows combinatorially with degree and input count, while the information in the data does not.
Boundary
Linear models that must stay interpretable or fast but need some nonlinearity.
Symptom or risk
Thousands of correlated columns, unstable coefficients, slow fitting and overfitting that only shows on held-out data.
Exceptions
With few inputs and large data, a full degree-2 expansion can be fine.
Trade-offs
Splines and selective products keep models readable; a tree ensemble may model nonlinearity more cheaply when interpretability is less critical.
Pitfalls
Expanding before scaling, which produces wildly different magnitudes across powers.
Lessons and concepts
Claims and their sources
PolynomialFeatures supports interaction_only to generate products without powers; SplineTransformer models each feature separately.