Kernel¶
Functions to calculate the kernel matrix - currently support the Radial Basis Function
-
kernel.
rbf
(x_train: numpy.ndarray, x_test: numpy.ndarray = None, params: numpy.ndarray = None) → numpy.ndarray[source]¶ Implementation of the Radial Basis Function
- Param
x_train (np.ndarray) : a matrix of size N x d (N > d)
- Param
x_test (np.ndarray) : a matrix (or vector)
- Param
params (np.ndarray) : kernel hyperparameters (amplitude and lengthscale)
- Returns
kernel_matrix (np.ndarray) : the kernel matrix
If the x_test is not part of the training set, following Rasmussen et al. (2006) the following will be returned:
- Returns
kernel_s (np.ndarray) : a vector of size N
- Returns
kernel_ss (np.ndarray) : a scalar (1 x 1) array
-
kernel.
squared_distance
(x1: numpy.ndarray, x2: numpy.ndarray, scale: numpy.ndarray) → numpy.ndarray[source]¶ Calculate the pairwise Euclidean distance between two input vectors (or matrix)
- Param
x1 (np.ndarray) : first vector (or matrix if we have more than 1 training point)
- Param
x2 (np.ndarray) : second vector (or matrix if we have more than 1 training point)
- Param
scale (np.ndarray) : the characteristic lengthscales for the kernel
- Returns
distance (np.ndarray) : pairwise Euclidean distance between the two vectors/matrix