smile.feature
Class Normalizer
- java.lang.Object
-
- smile.feature.FeatureTransform
-
- smile.feature.Normalizer
-
public class Normalizer extends FeatureTransform
Normalize samples individually to unit norm. Each sample (i.e. each row of the data matrix) with at least one non zero component is rescaled independently of other samples so that its norm (L1 or L2) equals one.Scaling inputs to unit norms is a common operation for text classification or clustering for instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classNormalizer.NormThe types of data scaling.
-
Constructor Summary
Constructors Constructor and Description Normalizer()Default constructor with L2 norm.Normalizer(boolean copy)Constructor with L2 norm.Normalizer(Normalizer.Norm norm)Constructor.Normalizer(Normalizer.Norm norm, boolean copy)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidlearn(Attribute[] attributes, double[][] data)Learns transformation parameters from a dataset.java.lang.StringtoString()double[]transform(double[] x)Transform a feature vector.-
Methods inherited from class smile.feature.FeatureTransform
learn, transform
-
-
-
-
Constructor Detail
-
Normalizer
public Normalizer()
Default constructor with L2 norm.
-
Normalizer
public Normalizer(boolean copy)
Constructor with L2 norm.- Parameters:
copy- If false, try to avoid a copy and do inplace scaling instead.
-
Normalizer
public Normalizer(Normalizer.Norm norm)
Constructor.- Parameters:
norm- The norm to use to normalize each non zero sample.
-
Normalizer
public Normalizer(Normalizer.Norm norm, boolean copy)
Constructor.- Parameters:
norm- The norm to use to normalize each non zero sample.copy- If false, try to avoid a copy and do inplace scaling instead.
-
-
Method Detail
-
learn
public void learn(Attribute[] attributes, double[][] data)
Description copied from class:FeatureTransformLearns transformation parameters from a dataset.- Specified by:
learnin classFeatureTransform- Parameters:
attributes- The variable attributes. Of which, numeric variables will be standardized.data- The training data to learn scaling parameters. The data will not be modified.
-
transform
public double[] transform(double[] x)
Description copied from class:FeatureTransformTransform a feature vector.- Specified by:
transformin classFeatureTransform- Parameters:
x- a feature vector.- Returns:
- the transformed feature value.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG