Polynomial kernel approximation via Tensor Sketch. Implements Tensor Sketch, which approximates the feature map of the polynomial kernel:: K(X, Y) = (gamma * + coef0)^degree by efficiently computing a Count Sketch of the outer product of a vector with itself using F
| 38 | |
| 39 | |
| 40 | class PolynomialCountSketch( |
| 41 | ClassNamePrefixFeaturesOutMixin, TransformerMixin, BaseEstimator |
| 42 | ): |
| 43 | """Polynomial kernel approximation via Tensor Sketch. |
| 44 | |
| 45 | Implements Tensor Sketch, which approximates the feature map |
| 46 | of the polynomial kernel:: |
| 47 | |
| 48 | K(X, Y) = (gamma * <X, Y> + coef0)^degree |
| 49 | |
| 50 | by efficiently computing a Count Sketch of the outer product of a |
| 51 | vector with itself using Fast Fourier Transforms (FFT). Read more in the |
| 52 | :ref:`User Guide <polynomial_kernel_approx>`. |
| 53 | |
| 54 | .. versionadded:: 0.24 |
| 55 | |
| 56 | Parameters |
| 57 | ---------- |
| 58 | gamma : float, default=1.0 |
| 59 | Parameter of the polynomial kernel whose feature map |
| 60 | will be approximated. |
| 61 | |
| 62 | degree : int, default=2 |
| 63 | Degree of the polynomial kernel whose feature map |
| 64 | will be approximated. |
| 65 | |
| 66 | coef0 : int, default=0 |
| 67 | Constant term of the polynomial kernel whose feature map |
| 68 | will be approximated. |
| 69 | |
| 70 | n_components : int, default=100 |
| 71 | Dimensionality of the output feature space. Usually, `n_components` |
| 72 | should be greater than the number of features in input samples in |
| 73 | order to achieve good performance. The optimal score / run time |
| 74 | balance is typically achieved around `n_components` = 10 * `n_features`, |
| 75 | but this depends on the specific dataset being used. |
| 76 | |
| 77 | random_state : int, RandomState instance, default=None |
| 78 | Determines random number generation for indexHash and bitHash |
| 79 | initialization. Pass an int for reproducible results across multiple |
| 80 | function calls. See :term:`Glossary <random_state>`. |
| 81 | |
| 82 | Attributes |
| 83 | ---------- |
| 84 | indexHash_ : ndarray of shape (degree, n_features), dtype=int64 |
| 85 | Array of indexes in range [0, n_components) used to represent |
| 86 | the 2-wise independent hash functions for Count Sketch computation. |
| 87 | |
| 88 | bitHash_ : ndarray of shape (degree, n_features), dtype=float32 |
| 89 | Array with random entries in {+1, -1}, used to represent |
| 90 | the 2-wise independent hash functions for Count Sketch computation. |
| 91 | |
| 92 | n_features_in_ : int |
| 93 | Number of features seen during :term:`fit`. |
| 94 | |
| 95 | .. versionadded:: 0.24 |
| 96 | |
| 97 | feature_names_in_ : ndarray of shape (`n_features_in_`,) |
searching dependent graphs…