deephyper.skopt.utils.HammingKernel#
- class deephyper.skopt.utils.HammingKernel(*args: Any, **kwargs: Any)[source]#
Bases:
StationaryKernelMixin
,NormalizedKernelMixin
,Kernel
The HammingKernel is used to handle categorical inputs.
K(x_1, x_2) = exp(\sum_{j=1}^{d} -ls_j * (I(x_1j != x_2j)))
- Parameters:
[float (* length_scale) – The length scale of the kernel. If a float, an isotropic kernel is used. If an array, an anisotropic kernel is used where each dimension of l defines the length-scale of the respective feature dimension.
array-like – The length scale of the kernel. If a float, an isotropic kernel is used. If an array, an anisotropic kernel is used where each dimension of l defines the length-scale of the respective feature dimension.
shape=[n_features – The length scale of the kernel. If a float, an isotropic kernel is used. If an array, an anisotropic kernel is used where each dimension of l defines the length-scale of the respective feature dimension.
] – The length scale of the kernel. If a float, an isotropic kernel is used. If an array, an anisotropic kernel is used where each dimension of l defines the length-scale of the respective feature dimension.
(default)] (1e5]) – The length scale of the kernel. If a float, an isotropic kernel is used. If an array, an anisotropic kernel is used where each dimension of l defines the length-scale of the respective feature dimension.
[array-like (* length_scale_bounds) – The lower and upper bound on length_scale
[1e-5 – The lower and upper bound on length_scale
(default)] – The lower and upper bound on length_scale
Methods
Computes gradient of K(x, X_train) with respect to x
Attributes
hyperparameter_length_scale
- __call__(X, Y=None, eval_gradient=False)[source]#
Return the kernel k(X, Y) and optionally its gradient.
Args: * X [array-like, shape=(n_samples_X, n_features)]
Left argument of the returned kernel k(X, Y)
- Y [array-like, shape=(n_samples_Y, n_features) or None(default)]
Right argument of the returned kernel k(X, Y). If None, k(X, X) if evaluated instead.
- eval_gradient [bool, False(default)]
Determines whether the gradient with respect to the kernel hyperparameter is determined. Only supported when Y is None.
Returns: * K [array-like, shape=(n_samples_X, n_samples_Y)]
Kernel k(X, Y)
- K_gradient [array-like, shape=(n_samples_X, n_samples_X, n_dims)]
The gradient of the kernel k(X, X) with respect to the hyperparameter of the kernel. Only returned when eval_gradient is True.
- gradient_x(x, X_train)#
Computes gradient of K(x, X_train) with respect to x
Args: x: array-like, shape=(n_features,)
A single test point.
- X_train: array-like, shape=(n_samples, n_features)
Training data used to fit the gaussian process.
Returns: gradient_x: array-like, shape=(n_samples, n_features)
Gradient of K(x, X_train) with respect to x.