MCPcopy Index your code
hub / github.com/scikit-learn/scikit-learn / transform

Method transform

sklearn/preprocessing/_data.py:2398–2427  ·  view source on GitHub ↗

Binarize each element of X. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) The data to binarize, element by element. scipy.sparse matrices should be in CSR format to avoid an un-necessary copy.

(self, X, copy=None)

Source from the content-addressed store, hash-verified

2396 return self
2397
2398 def transform(self, X, copy=None):
2399 """Binarize each element of X.
2400
2401 Parameters
2402 ----------
2403 X : {array-like, sparse matrix} of shape (n_samples, n_features)
2404 The data to binarize, element by element.
2405 scipy.sparse matrices should be in CSR format to avoid an
2406 un-necessary copy.
2407
2408 copy : bool
2409 Copy the input X or not.
2410
2411 Returns
2412 -------
2413 X_tr : {ndarray, sparse matrix} of shape (n_samples, n_features)
2414 Transformed array.
2415 """
2416 copy = copy if copy is not None else self.copy
2417 # TODO: This should be refactored because binarize also calls
2418 # check_array
2419 X = validate_data(
2420 self,
2421 X,
2422 accept_sparse=["csr", "csc"],
2423 force_writeable=True,
2424 copy=copy,
2425 reset=False,
2426 )
2427 return binarize(X, threshold=self.threshold, copy=False)
2428
2429 def __sklearn_tags__(self):
2430 tags = super().__sklearn_tags__()

Calls 2

validate_dataFunction · 0.90
binarizeFunction · 0.85