Class BinarySparsePolynomialKernel
java.lang.Object
smile.math.kernel.Polynomial
smile.math.kernel.BinarySparsePolynomialKernel
- All Implemented Interfaces:
Serializable, ToDoubleBiFunction<int[],int[]>, DotProductKernel, MercerKernel<int[]>, Function
The polynomial kernel on binary 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.
The kernel works on sparse binary array as int[], which are the indices of
nonzero elements.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionBinarySparsePolynomialKernel(int degree) Constructor with scale 1 and offset 0.BinarySparsePolynomialKernel(int degree, double scale, double offset) Constructor.BinarySparsePolynomialKernel(int degree, double scale, double offset, double[] lo, double[] hi) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]hi()Returns the upper bound of hyperparameters (in hyperparameter tuning).double[]Returns the hyperparameters of kernel.doublek(int[] x, int[] y) Kernel function.double[]kg(int[] x, int[] y) Computes the kernel and its gradient over hyperparameters.double[]lo()Returns the lower bound of hyperparameters (in hyperparameter tuning).of(double[] params) Returns the same kind kernel with the new hyperparameters.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface DotProductKernel
apply, f, KMethods inherited from interface MercerKernel
apply, applyAsDouble, K, K, KG
-
Constructor Details
-
BinarySparsePolynomialKernel
public BinarySparsePolynomialKernel(int degree) Constructor with scale 1 and offset 0.- Parameters:
degree- The degree of polynomial.
-
BinarySparsePolynomialKernel
public BinarySparsePolynomialKernel(int degree, double scale, double offset) Constructor.- Parameters:
degree- The degree of polynomial.scale- The scale parameter.offset- The offset parameter.
-
BinarySparsePolynomialKernel
public BinarySparsePolynomialKernel(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(int[] x, int[] y) Description copied from interface:MercerKernelKernel function.- Specified by:
kin interfaceMercerKernel<int[]>- Parameters:
x- an object.y- an object.- Returns:
- the kernel value.
-
kg
public double[] kg(int[] x, int[] y) Description copied from interface:MercerKernelComputes the kernel and its gradient over hyperparameters.- Specified by:
kgin interfaceMercerKernel<int[]>- Parameters:
x- an object.y- an object.- Returns:
- the kernel value and gradient.
-
of
Description copied from interface:MercerKernelReturns the same kind kernel with the new hyperparameters.- Specified by:
ofin interfaceMercerKernel<int[]>- Parameters:
params- the hyperparameters.- Returns:
- the same kind kernel with the new hyperparameters.
-
hyperparameters
public double[] hyperparameters()Description copied from interface:MercerKernelReturns the hyperparameters of kernel.- Specified by:
hyperparametersin interfaceMercerKernel<int[]>- Returns:
- the hyperparameters of kernel.
-
lo
public double[] lo()Description copied from interface:MercerKernelReturns the lower bound of hyperparameters (in hyperparameter tuning).- Specified by:
loin interfaceMercerKernel<int[]>- Returns:
- the lower bound of hyperparameters.
-
hi
public double[] hi()Description copied from interface:MercerKernelReturns the upper bound of hyperparameters (in hyperparameter tuning).- Specified by:
hiin interfaceMercerKernel<int[]>- Returns:
- the upper bound of hyperparameters.
-