org.apache.spark.mllib.feature
Class Normalizer
Object
org.apache.spark.mllib.feature.Normalizer
- All Implemented Interfaces:
- java.io.Serializable, VectorTransformer
public class Normalizer
- extends Object
- implements VectorTransformer
:: Experimental ::
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:
- Serialized Form
Methods inherited from class Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Normalizer
public Normalizer(double p)
Normalizer
public Normalizer()
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.