Class PolynomialExpansion

All Implemented Interfaces:
Serializable, org.apache.spark.internal.Logging, Params, HasInputCol, HasOutputCol, DefaultParamsWritable, Identifiable, MLWritable

public class PolynomialExpansion extends UnaryTransformer<Vector,Vector,PolynomialExpansion> implements DefaultParamsWritable
Perform feature expansion in a polynomial space. As said in wikipedia of Polynomial Expansion, which is available at Polynomial expansion (Wikipedia) , "In mathematics, an expansion of a product of sums expresses it as a sum of products by using the fact that multiplication distributes over addition". Take a 2-variable feature vector as an example: (x, y), if we want to expand it with degree 2, then we get (x, x * x, y, x * y, y * y).
See Also:
  • Constructor Details

    • PolynomialExpansion

      public PolynomialExpansion(String uid)
    • PolynomialExpansion

      public PolynomialExpansion()
  • Method Details

    • load

      public static PolynomialExpansion load(String path)
    • read

      public static MLReader<T> read()
    • uid

      public String uid()
      Description copied from interface: Identifiable
      An immutable unique ID for the object and its derivatives.
      Specified by:
      uid in interface Identifiable
      Returns:
      (undocumented)
    • degree

      public IntParam degree()
      The polynomial degree to expand, which should be greater than equal to 1. A value of 1 means no expansion. Default: 2
      Returns:
      (undocumented)
    • getDegree

      public int getDegree()
    • setDegree

      public PolynomialExpansion setDegree(int value)
    • copy

      public PolynomialExpansion copy(ParamMap extra)
      Description copied from interface: Params
      Creates a copy of this instance with the same UID and some extra params. Subclasses should implement this method and set the return type properly. See defaultCopy().
      Specified by:
      copy in interface Params
      Overrides:
      copy in class UnaryTransformer<Vector,Vector,PolynomialExpansion>
      Parameters:
      extra - (undocumented)
      Returns:
      (undocumented)
    • toString

      public String toString()
      Specified by:
      toString in interface Identifiable
      Overrides:
      toString in class Object