Scale input vectors individually to unit norm (vector length).
Read more in the User Guide.
The data to normalize, element by element. scipy.sparse matrices should be in CSR format to avoid an un-necessary copy.
The norm to use to normalize each non zero sample (or each non-zero feature if axis is 0).
Define axis used to normalize the data along. If 1, independently normalize each sample, otherwise (if 0) normalize each feature.
If False, try to avoid a copy and normalize in place. This is not guaranteed to always work in place; e.g. if the data is a numpy array with an int dtype, a copy will be returned even with copy=False.
Whether to return the computed norms.
Normalized input X.
An array of norms along given axis for X. When X is sparse, a NotImplementedError will be raised for norm ‘l1’ or ‘l2’.
See also
Normalizer
Performs normalization using the Transformer API (e.g. as part of a preprocessing Pipeline
).
Notes
For a comparison of the different scalers, transformers, and normalizers, see: Compare the effect of different scalers on data with outliers.
Examples
>>> from sklearn.preprocessing import normalize >>> X = [[-2, 1, 2], [-1, 0, 1]] >>> normalize(X, norm="l1") # L1 normalization each row independently array([[-0.4, 0.2, 0.4], [-0.5, 0. , 0.5]]) >>> normalize(X, norm="l2") # L2 normalization each row independently array([[-0.67, 0.33, 0.67], [-0.71, 0. , 0.71]])
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4