Class Normalizer

Object
org.apache.spark.mllib.feature.Normalizer
All Implemented Interfaces:
Serializable, VectorTransformer

public class Normalizer extends Object implements VectorTransformer
Normalizes samples individually to unit L^p^ norm

For any 1 <= p < Double.PositiveInfinity, normalizes samples using sum(abs(vector).^p^)^(1/p)^ as norm.

For p = Double.PositiveInfinity, max(abs(vector)) will be used as norm for normalization.

param: p Normalization in L^p^ space, p = 2 by default.

See Also:
  • Constructor Details

    • Normalizer

      public Normalizer(double p)
    • Normalizer

      public Normalizer()
  • Method Details

    • transform

      public Vector transform(Vector vector)
      Applies unit length normalization on a vector.

      Specified by:
      transform in interface VectorTransformer
      Parameters:
      vector - vector to be normalized.
      Returns:
      normalized vector. If the norm of the input is zero, it will return the input vector.