class sklearn.preprocessing.Normalizer(norm=’l2’, copy=True)
[source]
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.
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 l2normalized TFIDF 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.
Read more in the User Guide.
Parameters: 


See also
normalize
This estimator is stateless (besides constructor parameters), the fit method does nothing but is useful when used in a pipeline.
For a comparison of the different scalers, transformers, and normalizers, see examples/preprocessing/plot_all_scaling.py.
>>> from sklearn.preprocessing import Normalizer >>> X = [[4, 1, 2, 2], ... [1, 3, 9, 3], ... [5, 7, 5, 1]] >>> transformer = Normalizer().fit(X) # fit does nothing. >>> transformer Normalizer(copy=True, norm='l2') >>> transformer.transform(X) array([[0.8, 0.2, 0.4, 0.4], [0.1, 0.3, 0.9, 0.3], [0.5, 0.7, 0.5, 0.1]])
fit (X[, y])  Do nothing and return the estimator unchanged 
fit_transform (X[, y])  Fit to data, then transform it. 
get_params ([deep])  Get parameters for this estimator. 
set_params (**params)  Set the parameters of this estimator. 
transform (X[, y, copy])  Scale each non zero row of X to unit norm 
__init__(norm=’l2’, copy=True)
[source]
fit(X, y=None)
[source]
Do nothing and return the estimator unchanged
This method is just there to implement the usual API and hence work in pipelines.
Parameters: 


fit_transform(X, y=None, **fit_params)
[source]
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Parameters: 


Returns: 

get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: 


Returns: 

set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: 


transform(X, y=’deprecated’, copy=None)
[source]
Scale each non zero row of X to unit norm
Parameters: 


sklearn.preprocessing.Normalizer
© 2007–2018 The scikitlearn developers
Licensed under the 3clause BSD License.
http://scikitlearn.org/stable/modules/generated/sklearn.preprocessing.Normalizer.html