Radial basis function (RBF) / squared exponential kernel. Notes ----- For input vectors :math:`\mathbf{x}` and :math:`\mathbf{y}`, the radial basis function kernel is: .. math:: k(\mathbf{x}, \mathbf{y}) = \exp \left\{ -0.5
(self, sigma=None)
| 183 | |
| 184 | class RBFKernel(KernelBase): |
| 185 | def __init__(self, sigma=None): |
| 186 | """ |
| 187 | Radial basis function (RBF) / squared exponential kernel. |
| 188 | |
| 189 | Notes |
| 190 | ----- |
| 191 | For input vectors :math:`\mathbf{x}` and :math:`\mathbf{y}`, the radial |
| 192 | basis function kernel is: |
| 193 | |
| 194 | .. math:: |
| 195 | |
| 196 | k(\mathbf{x}, \mathbf{y}) = \exp \left\{ -0.5 |
| 197 | \left\lVert \\frac{\mathbf{x} - |
| 198 | \mathbf{y}}{\sigma} \\right\\rVert_2^2 \\right\} |
| 199 | |
| 200 | The RBF kernel decreases with distance and ranges between zero (in the |
| 201 | limit) to one (when **x** = **y**). Notably, the implied feature space |
| 202 | of the kernel has an infinite number of dimensions. |
| 203 | |
| 204 | Parameters |
| 205 | ---------- |
| 206 | sigma : float or array of shape `(C,)` or None |
| 207 | A scaling parameter for the vectors **x** and **y**, producing an |
| 208 | isotropic kernel if a float, or an anistropic kernel if an array of |
| 209 | length `C`. Larger values result in higher resolution / greater |
| 210 | smoothing. If None, defaults to :math:`\sqrt(C / 2)`. Sometimes |
| 211 | referred to as the kernel 'bandwidth'. Default is None. |
| 212 | """ |
| 213 | super().__init__() |
| 214 | self.hyperparameters = {"id": "RBFKernel"} |
| 215 | self.parameters = {"sigma": sigma} |
| 216 | |
| 217 | def _kernel(self, X, Y=None): |
| 218 | """ |