e 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. return_norm : bool, default=False Whether to return the computed norms. Returns ------- X : {ndarray, sparse matrix} of shape (n_samples, n_features) Normalized input X. norms : ndarray of shape (n_samples, ) if axis=1 else (n_features, ) 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 :class:`~sklearn.pipeline.Pipeline`). Notes ----- For a comparison of the different scalers, transformers, and normalizers, see: :ref:`sphx_glr_auto_examples_preprocessing_plot_all_scaling.py`. 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.66..., 0.33..., 0.66...], [-0.70..., 0. , 0.70...]]) r