Class SparsePolynomialKernel

java.lang.Object
smile.math.kernel.Polynomial
smile.math.kernel.SparsePolynomialKernel
All Implemented Interfaces:
Serializable, ToDoubleBiFunction<SparseArray,SparseArray>, Function, DotProductKernel, MercerKernel<SparseArray>

public class SparsePolynomialKernel extends Polynomial implements MercerKernel<SparseArray>
The polynomial kernel on sparse data.

k(u, v) = (γ uTv - λ)d

where γ is the scale of the used inner product, λ the offset of the used inner product, and d the order of the polynomial kernel.

See Also:
  • Constructor Details

    • SparsePolynomialKernel

      public SparsePolynomialKernel(int degree)
      Constructor with scale 1 and offset 0.
      Parameters:
      degree - The degree of polynomial.
    • SparsePolynomialKernel

      public SparsePolynomialKernel(int degree, double scale, double offset)
      Constructor.
      Parameters:
      degree - The degree of polynomial.
      scale - The scale parameter.
      offset - The offset parameter.
    • SparsePolynomialKernel

      public SparsePolynomialKernel(int degree, double scale, double offset, double[] lo, double[] hi)
      Constructor.
      Parameters:
      degree - The degree of polynomial. The degree is fixed during hyperparameter tuning.
      scale - The scale parameter.
      offset - The offset parameter.
      lo - The lower bound of scale and offset for hyperparameter tuning.
      hi - The upper bound of scale and offset for hyperparameter tuning.
  • Method Details

    • k

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

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

      public SparsePolynomialKernel of(double[] params)
      Description copied from interface: MercerKernel
      Returns the same kind kernel with the new hyperparameters.
      Specified by:
      of in interface MercerKernel<SparseArray>
      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<SparseArray>
      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<SparseArray>
      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<SparseArray>
      Returns:
      the upper bound of hyperparameters.