Basic configuration. You can skip configuration by providing no arguments.
In case no arguments are given you have to use the method fromConfig
to set up a
configuration in order to use the methods fit
, transform
and fitTransform
.
Optional
degree: numberHighest order of the monomials
Whether to include only highest order monomials
Whether to disallow higher powers of single features
Saves configuration to a simple option-bag.
The configuration specifies the internal state of PolynomialFeatures
completely. Hence the config of the transformer can be used to save it to a file.
Configuration option degree
Configuration option homogenous
Configuration option interactionOnly
Number of input features.
The only configuration option which is set by the fit
method.
Loads configuration from simple option-bag.
Transforms feature vectors to vectors of certain monomials thereof.
Example: Consider a feature vector
[a, b, c]
. After executingfitTransform
you get[a^2, ba, ca, a, b^2, cb, b, c^2, c, 1]
(degree = 2
), that is, all monomials ina
,b
,c
up to degree two.[a^2, ba, ca, b^2, cb, c^2]
(degree = 2
,homogeneous = true
), that is, all monomials of degree exactly equal to two.[ab, ac, bc]
(degree = 2
,homogeneous = true
,interactionOnly = true
), that is, all monomials of degree exactly equal to two and no feature raised to a power larger than one.[ab, ac, a, bc, b, c, 1]
(degree = 2
,homogeneous = false
,interactionOnly = true
), that is, all monomials of degree at most two and no feature raised to a power larger than one.Of course, the number of features is not restricted to three, but must be the same in each feature vector of the list to be transformed.