Package ai.sklearn4j.preprocessing.data
Class Normalizer
- java.lang.Object
-
- ai.sklearn4j.base.TransformerMixin<NumpyArray<Double>,NumpyArray<Double>>
-
- ai.sklearn4j.preprocessing.data.Normalizer
-
public class Normalizer extends TransformerMixin<NumpyArray<Double>,NumpyArray<Double>>
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, l2 or inf) equals one. This transformer is able to work both with dense numpy arrays and scipy.sparse matrix (use CSR format if you want to avoid the burden of a copy / conversion). Scaling inputs to unit norms is a common operation for text classification or clustering for instance. For instance the dot product of two l2-normalized TF-IDF vectors is the cosine similarity of the vectors and is the base similarity metric for the Vector Space Model commonly used by the Information Retrieval community.
-
-
Constructor Summary
Constructors Constructor Description Normalizer()Instantiate a new object of Normalizer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]getFeatureNamesIn()Gets the Names of features seen during `fit`.longgetNFeaturesIn()Gets the Number of features seen during `fit`.StringgetNorm()Gets the type of norm that the object performs.NumpyArray<Double>inverseTransform(NumpyArray<Double> array)Takes a transformed array and reveres the transformation.voidsetFeatureNamesIn(String[] value)Sets the Names of features seen during `fit`.voidsetNFeaturesIn(long value)Sets the Number of features seen during `fit`.voidsetNorm(String norm)Sets the type of norm that the object performs.NumpyArray<Double>transform(NumpyArray<Double> array)Takes the input array and transforms it.
-
-
-
Method Detail
-
setNFeaturesIn
public void setNFeaturesIn(long value)
Sets the Number of features seen during `fit`.- Parameters:
value- The new value for nFeaturesIn.
-
getNFeaturesIn
public long getNFeaturesIn()
Gets the Number of features seen during `fit`.
-
setFeatureNamesIn
public void setFeatureNamesIn(String[] value)
Sets the Names of features seen during `fit`. Defined only when `X` has feature names that are all strings.- Parameters:
value- The new value for featureNamesIn.
-
getFeatureNamesIn
public String[] getFeatureNamesIn()
Gets the Names of features seen during `fit`. Defined only when `X` has feature names that are all strings.
-
getNorm
public String getNorm()
Gets the type of norm that the object performs. The value is either l1, l2, or max.- Returns:
- The norm applied by the Normalizer.
-
setNorm
public void setNorm(String norm)
Sets the type of norm that the object performs. The value is either l1, l2, or max.- Parameters:
norm- The type of norm, either l1, l2, or max.
-
transform
public NumpyArray<Double> transform(NumpyArray<Double> array)
Takes the input array and transforms it.- Specified by:
transformin classTransformerMixin<NumpyArray<Double>,NumpyArray<Double>>- Parameters:
array- The array to transform.- Returns:
- The transformed array.
-
inverseTransform
public NumpyArray<Double> inverseTransform(NumpyArray<Double> array)
Takes a transformed array and reveres the transformation.- Specified by:
inverseTransformin classTransformerMixin<NumpyArray<Double>,NumpyArray<Double>>- Parameters:
array- The array to apply reveres transform.- Returns:
- The inversed transform of array.
-
-