Kernels#

Kernels are used by the Gaussian process in Bayesian optimization to model function similarity.

hyperoptax.kernels.cdist(x, y)[source]#

Pairwise Euclidean distance (cdist) between two 2-D arrays.

Parameters:
  • x (jax.Array) – Arrays with shape (N, D) and (M, D), respectively.

  • y (jax.Array) – Arrays with shape (N, D) and (M, D), respectively.

Returns:

A distance matrix of shape (N, M).

Return type:

jax.Array

class hyperoptax.kernels.BaseKernel[source]#

Bases: ABC

Abstract base class for positive-definite kernels.

class hyperoptax.kernels.RBF(length_scale=1.0)[source]#

Bases: BaseKernel

Radial basis function (RBF) / squared-exponential kernel.

Parameters:

length_scale (float)

__init__(length_scale=1.0)[source]#
Parameters:

length_scale (float)

class hyperoptax.kernels.Matern(length_scale=1.0, nu=2.5)[source]#

Bases: BaseKernel

Matern kernel family.

Parameters:
  • length_scale (float, default = 1.0) – Characteristic length scale.

  • nu (float, default = 2.5) – Controls smoothness (nu ∈ {0.5, 1.5, 2.5, ∞}).

__init__(length_scale=1.0, nu=2.5)[source]#
Parameters:

Usage Examples#

RBF Kernel#

from hyperoptax.kernels import RBF

# Create RBF kernel with length scale 1.0
kernel = RBF(length_scale=1.0)

Matern Kernel#

from hyperoptax.kernels import Matern

# Create Matern kernel with custom parameters
kernel = Matern(length_scale=1.0, nu=2.5)