Scale each non zero row of X to unit norm. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) The data to normalize, row by row. scipy.sparse matrices should be in CSR format to avoid an un-necessary copy.
(self, X, copy=None)
| 2195 | return self |
| 2196 | |
| 2197 | def transform(self, X, copy=None): |
| 2198 | """Scale each non zero row of X to unit norm. |
| 2199 | |
| 2200 | Parameters |
| 2201 | ---------- |
| 2202 | X : {array-like, sparse matrix} of shape (n_samples, n_features) |
| 2203 | The data to normalize, row by row. scipy.sparse matrices should be |
| 2204 | in CSR format to avoid an un-necessary copy. |
| 2205 | |
| 2206 | copy : bool, default=None |
| 2207 | Copy the input X or not. |
| 2208 | |
| 2209 | Returns |
| 2210 | ------- |
| 2211 | X_tr : {ndarray, sparse matrix} of shape (n_samples, n_features) |
| 2212 | Transformed array. |
| 2213 | """ |
| 2214 | copy = copy if copy is not None else self.copy |
| 2215 | X = validate_data( |
| 2216 | self, X, accept_sparse="csr", force_writeable=True, copy=copy, reset=False |
| 2217 | ) |
| 2218 | return normalize(X, norm=self.norm, axis=1, copy=False) |
| 2219 | |
| 2220 | def __sklearn_tags__(self): |
| 2221 | tags = super().__sklearn_tags__() |