Skip to main content

Module polynomial

Module polynomial 

Source
Expand description

PolynomialFeatures — expand a feature matrix into all monomials up to a given total degree.

The column ordering matches preprocessing.PolynomialFeatures and follows a graded lexicographic enumeration: first ascending total degree, then ascending lexicographic on the exponent vector.

§Complexity

For d input features and total degree p:

  • Output columns: include_bias: C(d + p, p), interaction_only: Σ_{k=0..=p} C(d, k).
  • Time: O(n · m) where m is the output-column count.
  • Space: O(m + n · m) for the returned matrix.

§Example

Degree 3, include_bias = true, interaction_only = false, d = 2 produces the columns [1, x0, x1, x0², x0·x1, x1², x0³, x0²·x1, x0·x1², x1³] — the same ordering the reference returns.

Structs§

PolynomialFeatures
Polynomial-feature expansion.