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

Method transform

sklearn/kernel_approximation.py:549–577  ·  view source on GitHub ↗

Apply the approximate feature map to X. Parameters ---------- X : array-like, shape (n_samples, n_features) New data, where `n_samples` is the number of samples and `n_features` is the number of features. All values of X must be strictly g

(self, X)

Source from the content-addressed store, hash-verified

547 return self
548
549 def transform(self, X):
550 """Apply the approximate feature map to X.
551
552 Parameters
553 ----------
554 X : array-like, shape (n_samples, n_features)
555 New data, where `n_samples` is the number of samples
556 and `n_features` is the number of features. All values of X must be
557 strictly greater than "-skewedness".
558
559 Returns
560 -------
561 X_new : array-like, shape (n_samples, n_components)
562 Returns the instance itself.
563 """
564 check_is_fitted(self)
565 X = validate_data(
566 self, X, copy=True, dtype=[np.float64, np.float32], reset=False
567 )
568 if (X <= -self.skewedness).any():
569 raise ValueError("X may not contain entries smaller than -skewedness.")
570
571 X += self.skewedness
572 np.log(X, X)
573 projection = safe_sparse_dot(X, self.random_weights_)
574 projection += self.random_offset_
575 np.cos(projection, projection)
576 projection *= np.sqrt(2.0) / np.sqrt(self.n_components)
577 return projection
578
579 def __sklearn_tags__(self):
580 tags = super().__sklearn_tags__()

Callers 1

test_skewed_chi2_samplerFunction · 0.95

Calls 3

check_is_fittedFunction · 0.90
validate_dataFunction · 0.90
safe_sparse_dotFunction · 0.90

Tested by 1

test_skewed_chi2_samplerFunction · 0.76