1

I am able to grasp the PolyFeature concept for 2nd degree transformation, as cleared here: Cannot understand with sklearn's PolynomialFeatures

But what if my input vector is [a,b,c] and I need to do a 4th degree transformation. How would my transformed vector then look like, if I keep interactions (interactions_only = False).

Would it be this:

[a,b,c, a^2, b^2,c^2,a^3, b^3,c^3, a^4, b^4,c^4, ab, bc, ca, a^2b^2,b^2c^2,c^2a^2,a^3b^3,b^3c^3,c^3a^3] 

or do the different degrees also interact, e.g. a^3b^2?

Stefan 44
  • 157
  • 1
  • 9

1 Answers1

2

With interactions_only=False , it will give all the combinations having a degree less or equal the degree you provide. Remembering that the degree of a given combination is the sum of the degrees of each individual variable in the combination (for example, a³ * b² has degree 5, a * b³ has degree 4 etc).

For example, for degree 3, it will give:

[1, a, b, c, a², b², c², a³, b³, c³, ab, ac, bc, a²b, a²c, b²a, b²c, c²a, c²b, abc]

With interactions_only=True , it will give all the combinations having degree less or equal the degree you provide with each individual term in the combination having degree less or equal 1.

For example, for degree 3, it will give:

[1, a, b, c, ab, ac, bc, abc]

Source: the scikit learn user guide

joaopfg
  • 1,227
  • 2
  • 9
  • 18