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)
| 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__() |