Interface MercerKernel<T>

Type Parameters:
T - the input type of kernel function.
All Superinterfaces:
Serializable, ToDoubleBiFunction<T,T>
All Known Implementing Classes:
BinarySparseGaussianKernel, BinarySparseHyperbolicTangentKernel, BinarySparseLaplacianKernel, BinarySparseLinearKernel, BinarySparseMaternKernel, BinarySparsePolynomialKernel, BinarySparseThinPlateSplineKernel, GaussianKernel, HellingerKernel, HyperbolicTangentKernel, LaplacianKernel, LinearKernel, MaternKernel, PearsonKernel, PolynomialKernel, ProductKernel, SparseGaussianKernel, SparseHyperbolicTangentKernel, SparseLaplacianKernel, SparseLinearKernel, SparseMaternKernel, SparsePolynomialKernel, SparseThinPlateSplineKernel, SumKernel, ThinPlateSplineKernel

public interface MercerKernel<T> extends ToDoubleBiFunction<T,T>, Serializable
Mercer kernel, also called covariance function in Gaussian process. A kernel is a continuous function that takes two variables x and y and map them to a real value such that k(x,y) = k(y,x). A Mercer kernel is a kernel that is positive Semi-definite. When a kernel is positive semi-definite, one may exploit the kernel trick, the idea of implicitly mapping data to a high-dimensional feature space where some linear algorithm is applied that works exclusively with inner products. Assume we have some mapping Φ from an input space X to a feature space H, then a kernel k(u, v) = <&#934;(u), &#934;(v)> may be used to define the inner product in feature space H.

Positive definiteness in the context of kernel functions also implies that a kernel matrix created using a particular kernel is positive semi-definite. A matrix is positive semi-definite if its associated eigenvalues are non-negative.

We can combine or modify existing kernel functions to make new one. For example, the sum of two kernels is a kernel. The product of two kernels is also a kernel.

A stationary covariance function is a function of distance x − y. Thus, it is invariant stationarity to translations in the input space. If further the covariance function is a function only of |x − y| then it is called isotropic; it is thus invariant to all rigid motions. If a covariance function depends only on the dot product of x and y, we call it a dot product covariance function.

  • Method Summary

    Modifier and Type
    Method
    Description
    default double
    apply(T x, T y)
    Kernel function.
    default double
    applyAsDouble(T x, T y)
     
    static MercerKernel<int[]>
    binary(String kernel)
    Returns a binary sparse kernel function.
    double[]
    hi()
    Returns the upper bound of hyperparameters (in hyperparameter tuning).
    double[]
    Returns the hyperparameters of kernel.
    double
    k(T x, T y)
    Kernel function.
    default Matrix
    K(T[] x)
    Computes the kernel matrix.
    default Matrix
    K(T[] x, T[] y)
    Returns the kernel matrix.
    double[]
    kg(T x, T y)
    Computes the kernel and its gradient over hyperparameters.
    default Matrix[]
    KG(T[] x)
    Computes the kernel and gradient matrices.
    double[]
    lo()
    Returns the lower bound of hyperparameters (in hyperparameter tuning).
    of(double[] params)
    Returns the same kind kernel with the new hyperparameters.
    static MercerKernel<double[]>
    of(String kernel)
    Returns a kernel function.
    sparse(String kernel)
    Returns a sparse kernel function.
  • Method Details

    • k

      double k(T x, T y)
      Kernel function.
      Parameters:
      x - an object.
      y - an object.
      Returns:
      the kernel value.
    • kg

      double[] kg(T x, T y)
      Computes the kernel and its gradient over hyperparameters.
      Parameters:
      x - an object.
      y - an object.
      Returns:
      the kernel value and gradient.
    • apply

      default double apply(T x, T y)
      Kernel function. This is simply for Scala convenience.
      Parameters:
      x - an object.
      y - an object.
      Returns:
      the kernel value.
    • applyAsDouble

      default double applyAsDouble(T x, T y)
      Specified by:
      applyAsDouble in interface ToDoubleBiFunction<T,T>
    • KG

      default Matrix[] KG(T[] x)
      Computes the kernel and gradient matrices.
      Parameters:
      x - objects.
      Returns:
      the kernel and gradient matrices.
    • K

      default Matrix K(T[] x)
      Computes the kernel matrix.
      Parameters:
      x - objects.
      Returns:
      the kernel matrix.
    • K

      default Matrix K(T[] x, T[] y)
      Returns the kernel matrix.
      Parameters:
      x - objects.
      y - objects.
      Returns:
      the kernel matrix.
    • of

      MercerKernel<T> of(double[] params)
      Returns the same kind kernel with the new hyperparameters.
      Parameters:
      params - the hyperparameters.
      Returns:
      the same kind kernel with the new hyperparameters.
    • hyperparameters

      double[] hyperparameters()
      Returns the hyperparameters of kernel.
      Returns:
      the hyperparameters of kernel.
    • lo

      double[] lo()
      Returns the lower bound of hyperparameters (in hyperparameter tuning).
      Returns:
      the lower bound of hyperparameters.
    • hi

      double[] hi()
      Returns the upper bound of hyperparameters (in hyperparameter tuning).
      Returns:
      the upper bound of hyperparameters.
    • of

      static MercerKernel<double[]> of(String kernel)
      Returns a kernel function.
      Parameters:
      kernel - the kernel function string representation.
      Returns:
      the kernel function.
    • sparse

      static MercerKernel<SparseArray> sparse(String kernel)
      Returns a sparse kernel function.
      Parameters:
      kernel - the kernel function string representation.
      Returns:
      the kernel function.
    • binary

      static MercerKernel<int[]> binary(String kernel)
      Returns a binary sparse kernel function.
      Parameters:
      kernel - the kernel function string representation.
      Returns:
      the kernel function.