surrogate.kernels

surrogate.kernels

Classes

Name Description
ConstantKernel Constant kernel.
Kernel Base class for Kernels.
Product The Product kernel k1 * k2.
RBF Radial Basis Function (RBF) kernel.
SpotOptimKernel Kernel designed for SpotOptim’s Kriging with mixed variable support.
Sum The Sum kernel k1 + k2.
WhiteKernel White kernel.

ConstantKernel

surrogate.kernels.ConstantKernel(
    constant_value=1.0,
    constant_value_bounds=(1e-05, 100000.0),
)

Constant kernel.

Can be used as a scaling factor (e.g. 2.0 * RBF()) or as part of a sum (e.g. RBF() + 1.0).

Parameters

Name Type Description Default
constant_value float The constant value. Defaults to 1.0. 1.0
constant_value_bounds tuple The lower and upper bound on constant_value. Defaults to (1e-5, 1e5). (1e-05, 100000.0)

Kernel

surrogate.kernels.Kernel()

Base class for Kernels.

Methods

Name Description
diag Returns the diagonal of the kernel k(X, X).
diag
surrogate.kernels.Kernel.diag(X)

Returns the diagonal of the kernel k(X, X).

The result of this method is equivalent to np.diag(self(X)); however, it can be evaluated more efficiently.

Parameters
Name Type Description Default
X np.ndarray Argument of the kernel evaluation. required
Returns
Name Type Description
np.ndarray np.ndarray: Diagonal of the kernel matrix, shape (n_samples_X,).

Product

surrogate.kernels.Product(k1, k2)

The Product kernel k1 * k2.

The kernel value is k1(X, Y) * k2(X, Y).

Parameters

Name Type Description Default
k1 Kernel First kernel. required
k2 Kernel Second kernel. required

RBF

surrogate.kernels.RBF(length_scale=1.0, length_scale_bounds=(1e-05, 100000.0))

Radial Basis Function (RBF) kernel.

Also known as the “squared exponential” kernel. It is given by: k(x_i, x_j) = exp(-0.5 * d(x_i, x_j)^2 / length_scale^2)

Parameters

Name Type Description Default
length_scale float or np.ndarray The length scale of the kernel. If a float, using isotropic distances. If an array, using anisotropic distances. Defaults to 1.0. 1.0
length_scale_bounds tuple The lower and upper bound on length_scale. Defaults to (1e-5, 1e5). (1e-05, 100000.0)

SpotOptimKernel

surrogate.kernels.SpotOptimKernel(
    theta,
    var_type,
    p_val=2.0,
    metric_factorial='canberra',
)

Kernel designed for SpotOptim’s Kriging with mixed variable support.

It handles continuous (‘float’), integer (‘int’), and categorical (‘factor’) variables similarly to the internal logic of the Kriging class.

The correlation function is defined as: Psi = exp(- (D_ordered + D_factor))

where: D_ordered = sum_j theta_j * |x_ij - y_lj|^p (for ordered variables) D_factor = sum_j theta_j * d(x_ij, y_lj) (for factor variables, d is metric like Canberra)

Parameters

Name Type Description Default
theta np.ndarray The correlation parameters (weights). Note: In standard Kriging usage, this corresponds to 10^theta_log. This kernel expects the LINEAR scale theta values (weights), not log. required
var_type list of str List of variable types, e.g. [‘float’, ‘int’, ‘factor’]. required
p_val float Power parameter for ordered distance. Defaults to 2.0. 2.0
metric_factorial str Metric for factor distance (passed to cdist/pdist). Defaults to ‘canberra’. 'canberra'

Sum

surrogate.kernels.Sum(k1, k2)

The Sum kernel k1 + k2.

The kernel value is k1(X, Y) + k2(X, Y).

Parameters

Name Type Description Default
k1 Kernel First kernel. required
k2 Kernel Second kernel. required

WhiteKernel

surrogate.kernels.WhiteKernel(
    noise_level=1.0,
    noise_level_bounds=(1e-05, 100000.0),
)

White kernel.

The main use case is capturing noise in the signal: k(x_i, x_j) = noise_level if x_i == x_j else 0

Parameters

Name Type Description Default
noise_level float Parameter controlling the noise level (variance). Defaults to 1.0. 1.0
noise_level_bounds tuple The lower and upper bound on noise_level. Defaults to (1e-5, 1e5). (1e-05, 100000.0)