Skip to content
ML Academy

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

  1. Situation

    You apply PolynomialFeatures of degree 3 or more to dozens of inputs to capture nonlinearity.

  2. 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.

  3. Reason

    The number of terms grows combinatorially with degree and input count, while the information in the data does not.

  4. 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