Class BinarySparseGaussianKernel

java.lang.Object
smile.math.kernel.Gaussian
smile.math.kernel.BinarySparseGaussianKernel
All Implemented Interfaces:
Serializable, ToDoubleBiFunction<int[],int[]>, Function, IsotropicKernel, MercerKernel<int[]>

public class BinarySparseGaussianKernel extends Gaussian implements MercerKernel<int[]>
Gaussian kernel, also referred as RBF kernel or squared exponential kernel.

k(u, v) = exp(-||u-v||2 / 2σ2)

where σ > 0 is the scale parameter of the kernel. The kernel works on sparse binary array as int[], which are the indices of nonzero elements.

The Gaussian kernel is a good choice for a great deal of applications, although sometimes it is remarked as being overused.

See Also:
  • Constructor Details

    • BinarySparseGaussianKernel

      public BinarySparseGaussianKernel(double sigma)
      Constructor.
      Parameters:
      sigma - The length scale of kernel.
    • BinarySparseGaussianKernel

      public BinarySparseGaussianKernel(double sigma, double lo, double hi)
      Constructor.
      Parameters:
      sigma - The length scale of kernel.
      lo - The lower bound of length scale for hyperparameter tuning.
      hi - The upper bound of length scale for hyperparameter tuning.
  • Method Details

    • k

      public double k(int[] x, int[] y)
      Description copied from interface: MercerKernel
      Kernel function.
      Specified by:
      k in interface MercerKernel<int[]>
      Parameters:
      x - an object.
      y - an object.
      Returns:
      the kernel value.
    • kg

      public double[] kg(int[] x, int[] y)
      Description copied from interface: MercerKernel
      Computes the kernel and its gradient over hyperparameters.
      Specified by:
      kg in interface MercerKernel<int[]>
      Parameters:
      x - an object.
      y - an object.
      Returns:
      the kernel value and gradient.
    • of

      public BinarySparseGaussianKernel of(double[] params)
      Description copied from interface: MercerKernel
      Returns the same kind kernel with the new hyperparameters.
      Specified by:
      of in interface MercerKernel<int[]>
      Parameters:
      params - the hyperparameters.
      Returns:
      the same kind kernel with the new hyperparameters.
    • hyperparameters

      public double[] hyperparameters()
      Description copied from interface: MercerKernel
      Returns the hyperparameters of kernel.
      Specified by:
      hyperparameters in interface MercerKernel<int[]>
      Returns:
      the hyperparameters of kernel.
    • lo

      public double[] lo()
      Description copied from interface: MercerKernel
      Returns the lower bound of hyperparameters (in hyperparameter tuning).
      Specified by:
      lo in interface MercerKernel<int[]>
      Returns:
      the lower bound of hyperparameters.
    • hi

      public double[] hi()
      Description copied from interface: MercerKernel
      Returns the upper bound of hyperparameters (in hyperparameter tuning).
      Specified by:
      hi in interface MercerKernel<int[]>
      Returns:
      the upper bound of hyperparameters.