MCPcopy
hub / github.com/scikit-learn/scikit-learn / transform

Method transform

sklearn/kernel_approximation.py:395–416  ·  view source on GitHub ↗

Apply the approximate feature map to X. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) New data, where `n_samples` is the number of samples and `n_features` is the number of features. Returns ----

(self, X)

Source from the content-addressed store, hash-verified

393 return self
394
395 def transform(self, X):
396 """Apply the approximate feature map to X.
397
398 Parameters
399 ----------
400 X : {array-like, sparse matrix}, shape (n_samples, n_features)
401 New data, where `n_samples` is the number of samples
402 and `n_features` is the number of features.
403
404 Returns
405 -------
406 X_new : array-like, shape (n_samples, n_components)
407 Returns the instance itself.
408 """
409 check_is_fitted(self)
410
411 X = validate_data(self, X, accept_sparse="csr", reset=False)
412 projection = safe_sparse_dot(X, self.random_weights_)
413 projection += self.random_offset_
414 np.cos(projection, projection)
415 projection *= (2.0 / self.n_components) ** 0.5
416 return projection
417
418 def __sklearn_tags__(self):
419 tags = super().__sklearn_tags__()

Callers 1

test_rbf_samplerFunction · 0.95

Calls 3

check_is_fittedFunction · 0.90
validate_dataFunction · 0.90
safe_sparse_dotFunction · 0.90

Tested by 1

test_rbf_samplerFunction · 0.76