def kernel_periodic(matrix_1, matrix_2, parameters): p = parameters[0] l = parameters[1] matrix = norm_matrix(matrix_1, matrix_2) K = np.exp(-np.sin(matrix * np.pi / p)**2 / l**2) return K
def kernel_gaussian_linear(matrix_1, matrix_2, parameters): K = 0 matrix = norm_matrix(matrix_1, matrix_2) for i in range(parameters.shape[1]): # print("beta", parameters[1, i]) # print("sigma", parameters[0, i]) K = K + parameters[1, i]**2 * np.exp(-matrix / (2 * parameters[0, i]**2)) return K
def kernel_bernoulli(matrix_1, matrix_2, parameters): matrix = norm_matrix(matrix_1, matrix_2) alpha_0 = parameters[0] sigma_0 = parameters[1] alpha_1 = parameters[2] sigma_1 = parameters[3] K = alpha_0 * np.maximum(0, 1 - matrix / (sigma_0)) + alpha_1 * np.exp(-matrix / (2 * sigma_1**2)) return K
def kernel_rational_quadratic_gaussian(matrix_1, matrix_2, parameters): alpha = parameters[0] beta = parameters[1] sigma = parameters[2] delta_1 = parameters[3] delta_2 = parameters[4] c = parameters[5] matrix = norm_matrix(matrix_1, matrix_2) K = c + delta_1**2 * ( (beta**2 + matrix)**(-(alpha))) + delta_2**2 * np.exp(-matrix / (2 * sigma**2)) return K
def kernel_cauchy(matrix_1, matrix_2, parameters): sigma = parameters[0] matrix = norm_matrix(matrix_1, matrix_2) return 1 / (1 + matrix / sigma**2)
def kernel_inverse_multiquad(matrix_1, matrix_2, parameters): beta = parameters[0] gamma = parameters[1] matrix = norm_matrix(matrix_1, matrix_2) return (beta**2 + gamma * matrix)**(-1 / 2)
def kernel_inverse_power_alpha(matrix_1, matrix_2, parameters): alpha = parameters[0] beta = 1.0 epsilon = 0.0001 matrix = norm_matrix(matrix_1, matrix_2) return (beta**2 + matrix)**(-(alpha + epsilon))
def kernel_rational_quadratic(matrix_1, matrix_2, parameters): alpha = parameters[0] beta = parameters[1] epsilon = 0.0001 matrix = norm_matrix(matrix_1, matrix_2) return (beta**2 + matrix)**(-(alpha + epsilon))
def kernel_laplacian(matrix_1, matrix_2, parameters): gamma = parameters[0] matrix = np.sqrt(norm_matrix(matrix_1, matrix_2)) K = np.exp(-matrix * gamma) return K
def kernel_RBF(matrix_1, matrix_2, parameters): matrix = norm_matrix(matrix_1, matrix_2) sigma = parameters[0] K = np.exp(-matrix / (2 * sigma**2)) return K