Class Polynomial

java.lang.Object
smile.math.kernel.Polynomial
All Implemented Interfaces:
Serializable, Function, DotProductKernel
Direct Known Subclasses:
BinarySparsePolynomialKernel, PolynomialKernel, SparsePolynomialKernel

public class Polynomial extends Object implements DotProductKernel
The polynomial kernel.

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 Summary

    Constructors
    Constructor
    Description
    Polynomial(int degree, double scale, double offset, double[] lo, double[] hi)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the degree of polynomial.
    double
    k(double dot)
    Computes the dot product kernel function.
    double[]
    kg(double dot)
    Computes the dot product kernel function and its gradient over hyperparameters.
    double
    Returns the offset of kernel.
    double
    Returns the scale of kernel.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface smile.math.kernel.DotProductKernel

    apply, f, K

    Methods inherited from interface smile.math.Function

    inv
  • Constructor Details

    • Polynomial

      public Polynomial(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

    • degree

      public int degree()
      Returns the degree of polynomial.
      Returns:
      the degree of polynomial.
    • scale

      public double scale()
      Returns the scale of kernel.
      Returns:
      the scale of kernel.
    • offset

      public double offset()
      Returns the offset of kernel.
      Returns:
      the offset of kernel.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • k

      public double k(double dot)
      Description copied from interface: DotProductKernel
      Computes the dot product kernel function.
      Specified by:
      k in interface DotProductKernel
      Parameters:
      dot - the dot product.
      Returns:
      the kernel value.
    • kg

      public double[] kg(double dot)
      Description copied from interface: DotProductKernel
      Computes the dot product kernel function and its gradient over hyperparameters.
      Specified by:
      kg in interface DotProductKernel
      Parameters:
      dot - The dot product.
      Returns:
      the kernel value and gradient.