Base kernels
smac.model.gaussian_process.kernels.base_kernels
#
AbstractKernel
#
AbstractKernel(
*,
operate_on: ndarray | None = None,
has_conditions: bool = False,
prior: AbstractPrior | None = None,
**kwargs: Any
)
This is a mixin for a kernel to override functions of the kernel. Because it overrides functions of the kernel,
it needs to be placed first in the inheritance hierarchy. For this reason it is not possible to subclass the
Mixin from the kernel class because this will prevent it from being instantiatable. Therefore, mypy won't know about
anything related to the superclass and some type:ignore statements has to be added when accessing a member that is
declared in the superclass such as self.has_conditions
, self._call
, super().get_params
, etc.
Parameters#
operate_on : np.ndarray, defaults to None On which numpy array should be operated on. has_conditions : bool, defaults to False Whether the kernel has conditions. prior : AbstractPrior, defaults to None Which prior the kernel is using.
Attributes#
operate_on : np.ndarray, defaults to None On which numpy array should be operated on. has_conditions : bool, defaults to False Whether the kernel has conditions. Might be changed by the gaussian process. prior : AbstractPrior, defaults to None Which prior the kernel is using. Primarily used by sklearn.
Source code in smac/model/gaussian_process/kernels/base_kernels.py
hyperparameters
property
#
hyperparameters: list[Hyperparameter]
Returns a list of all hyperparameter specifications.
meta
property
#
Returns the meta data of the created object. This method calls the get_params
method to collect the
parameters of the kernel.
__call__
#
__call__(
X: ndarray,
Y: ndarray | None = None,
eval_gradient: bool = False,
active: ndarray | None = None,
) -> ndarray | tuple[ndarray, ndarray]
Call the kernel function. Internally, self._call
is called, which must be specified by a subclass.
Source code in smac/model/gaussian_process/kernels/base_kernels.py
get_params
#
Get parameters of this kernel.
Parameters#
deep : bool, defaults to True If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns#
params : dict[str, Any] Parameter names mapped to their values.
Source code in smac/model/gaussian_process/kernels/base_kernels.py
ConstantKernel
#
ConstantKernel(
constant_value: float = 1.0,
constant_value_bounds: tuple[float, float] = (
1e-05,
100000.0,
),
operate_on: ndarray | None = None,
has_conditions: bool = False,
prior: AbstractPrior | None = None,
)
Bases: AbstractKernel
, ConstantKernel
Source code in smac/model/gaussian_process/kernels/base_kernels.py
hyperparameters
property
#
hyperparameters: list[Hyperparameter]
Returns a list of all hyperparameter specifications.
meta
property
#
Returns the meta data of the created object. This method calls the get_params
method to collect the
parameters of the kernel.
__call__
#
__call__(
X: ndarray,
Y: ndarray | None = None,
eval_gradient: bool = False,
active: ndarray | None = None,
) -> ndarray | tuple[ndarray, ndarray]
Return the kernel k(X, Y) and optionally its gradient.
Parameters#
X : np.ndarray, shape (n_samples_X, n_features) Left argument of the returned kernel k(X, Y).
np.ndarray, shape (n_samples_Y, n_features), (optional, default=None)
Right argument of the returned kernel k(X, Y). If None, k(X, X) is evaluated instead.
bool (optional, default=False)
Determines whether the gradient with respect to the kernel hyperparameter is determined. Only supported when Y is None.
np.ndarray (n_samples_X, n_features) (optional)
Boolean array specifying which hyperparameters are active.
Returns#
K : np.ndarray, shape (n_samples_X, n_samples_Y) Kernel k(X, Y).
np.ndarray (opt.), 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.
Source code in smac/model/gaussian_process/kernels/base_kernels.py
get_params
#
Get parameters of this kernel.
Parameters#
deep : bool, defaults to True If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns#
params : dict[str, Any] Parameter names mapped to their values.
Source code in smac/model/gaussian_process/kernels/base_kernels.py
ProductKernel
#
ProductKernel(
k1: Kernel,
k2: Kernel,
operate_on: ndarray | None = None,
has_conditions: bool = False,
)
Bases: AbstractKernel
, Product
Product kernel implementation.
Source code in smac/model/gaussian_process/kernels/base_kernels.py
hyperparameters
property
#
hyperparameters: list[Hyperparameter]
Returns a list of all hyperparameter specifications.
meta
property
#
Returns the meta data of the created object. This method calls the get_params
method to collect the
parameters of the kernel.
__call__
#
__call__(
X: ndarray,
Y: ndarray | None = None,
eval_gradient: bool = False,
active: ndarray | None = None,
) -> ndarray | tuple[ndarray, ndarray]
Return the kernel k(X, Y) and optionally its gradient.
Parameters#
X : np.ndarray, shape (n_samples_X, n_features) Left argument of the returned kernel k(X, Y).
np.ndarray, shape (n_samples_Y, n_features), (optional, default=None)
Right argument of the returned kernel k(X, Y). If None, k(X, X) is evaluated instead.
bool (optional, default=False)
Determines whether the gradient with respect to the kernel hyperparameter is determined.
np.ndarray (n_samples_X, n_features) (optional)
Boolean array specifying which hyperparameters are active.
Returns#
K : np.ndarray, shape (n_samples_X, n_samples_Y) Kernel k(X, Y).
np.ndarray (opt.), 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.
Source code in smac/model/gaussian_process/kernels/base_kernels.py
get_params
#
Get parameters of this kernel.
Parameters#
deep : bool, defaults to True If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns#
params : dict[str, Any] Parameter names mapped to their values.
Source code in smac/model/gaussian_process/kernels/base_kernels.py
SumKernel
#
SumKernel(
k1: Kernel,
k2: Kernel,
operate_on: ndarray | None = None,
has_conditions: bool = False,
)
Bases: AbstractKernel
, Sum
Sum kernel implementation.
Source code in smac/model/gaussian_process/kernels/base_kernels.py
hyperparameters
property
#
hyperparameters: list[Hyperparameter]
Returns a list of all hyperparameter specifications.
meta
property
#
Returns the meta data of the created object. This method calls the get_params
method to collect the
parameters of the kernel.
__call__
#
__call__(
X: ndarray,
Y: ndarray | None = None,
eval_gradient: bool = False,
active: ndarray | None = None,
) -> ndarray | tuple[ndarray, ndarray]
Return the kernel k(X, Y) and optionally its gradient.
Parameters#
X : np.ndarray, shape (n_samples_X, n_features) Left argument of the returned kernel k(X, Y).
np.ndarray, shape (n_samples_Y, n_features), (optional, default=None)
Right argument of the returned kernel k(X, Y). If None, k(X, X) is evaluated instead.
bool (optional, default=False)
Determines whether the gradient with respect to the kernel hyperparameter is determined.
np.ndarray (n_samples_X, n_features) (optional)
Boolean array specifying which hyperparameters are active.
Returns#
K : np.ndarray, shape (n_samples_X, n_samples_Y) Kernel k(X, Y).
np.ndarray (opt.), 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.
Source code in smac/model/gaussian_process/kernels/base_kernels.py
get_params
#
Get parameters of this kernel.
Parameters#
deep : bool, defaults to True If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns#
params : dict[str, Any] Parameter names mapped to their values.