Class GaussianKernel
java.lang.Object
smile.math.kernel.Gaussian
smile.math.kernel.GaussianKernel
- All Implemented Interfaces:
Serializable, ToDoubleBiFunction<double[],double[]>, IsotropicKernel, MercerKernel<double[]>, Function
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 Gaussian kernel is a good choice for a great deal of applications, although sometimes it is remarked as being overused.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionGaussianKernel(double sigma) Constructor.GaussianKernel(double sigma, 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(double[] x, double[] y) Kernel function.double[]kg(double[] x, double[] 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 IsotropicKernel
apply, f, K, KGMethods inherited from interface MercerKernel
apply, applyAsDouble, K, K, KG
-
Constructor Details
-
GaussianKernel
public GaussianKernel(double sigma) Constructor.- Parameters:
sigma- The length scale of kernel.
-
GaussianKernel
public GaussianKernel(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(double[] x, double[] y) Description copied from interface:MercerKernelKernel function.- Specified by:
kin interfaceMercerKernel<double[]>- Parameters:
x- an object.y- an object.- Returns:
- the kernel value.
-
kg
public double[] kg(double[] x, double[] y) Description copied from interface:MercerKernelComputes the kernel and its gradient over hyperparameters.- Specified by:
kgin interfaceMercerKernel<double[]>- 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<double[]>- 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<double[]>- 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<double[]>- 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<double[]>- Returns:
- the upper bound of hyperparameters.
-