jsat.distributions.kernels
Class RationalQuadraticKernel
- java.lang.Object
-
- jsat.distributions.kernels.BaseL2Kernel
-
- jsat.distributions.kernels.RationalQuadraticKernel
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, KernelTrick, Parameterized
public class RationalQuadraticKernel extends BaseL2Kernel
Provides an implementation of the Rational Quadratic Kernel, which is of the form:
k(x, y) = 1 - ||x-y||2 / (||x-y||2 + c)- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description RationalQuadraticKernel(double c)Creates a new RQ Kernel
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description RationalQuadraticKernelclone()doubleeval(int a, int b, java.util.List<? extends Vec> trainingSet, java.util.List<java.lang.Double> cache)Produces the correct kernel evaluation given the training set and the cache generated byKernelTrick.getAccelerationCache(List).doubleeval(int a, Vec b, java.util.List<java.lang.Double> qi, java.util.List<? extends Vec> vecs, java.util.List<java.lang.Double> cache)Computes the kernel product between one vector in the original list of vectors with that of another vector not from the original list, but had information generated byKernelTrick.getQueryInfo(jsat.linear.Vec).doubleeval(Vec a, Vec b)Evaluate this kernel function for the two given vectors.doublegetC()Returns the positive additive coefficientstatic DistributionguessC(DataSet d)Guess the distribution to use for the C parameter.booleannormalized()This method indicates if a kernel is a normalized kernel or not.voidsetC(double c)Sets the positive additive coefficient-
Methods inherited from class jsat.distributions.kernels.BaseL2Kernel
addToCache, evalSum, evalSum, getAccelerationCache, getQueryInfo, supportsAcceleration
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.distributions.kernels.KernelTrick
toString
-
Methods inherited from interface jsat.parameters.Parameterized
getParameter, getParameters
-
-
-
-
Constructor Detail
-
RationalQuadraticKernel
public RationalQuadraticKernel(double c)
Creates a new RQ Kernel- Parameters:
c- the positive additive coefficient
-
-
Method Detail
-
setC
public void setC(double c)
Sets the positive additive coefficient- Parameters:
c- the positive additive coefficient
-
getC
public double getC()
Returns the positive additive coefficient- Returns:
- the positive additive coefficient
-
eval
public double eval(Vec a, Vec b)
Description copied from interface:KernelTrickEvaluate this kernel function for the two given vectors.- Specified by:
evalin interfaceKernelTrick- Specified by:
evalin classBaseL2Kernel- Parameters:
a- the first vectorb- the first vector- Returns:
- the evaluation
-
eval
public double eval(int a, int b, java.util.List<? extends Vec> trainingSet, java.util.List<java.lang.Double> cache)Description copied from interface:KernelTrickProduces the correct kernel evaluation given the training set and the cache generated byKernelTrick.getAccelerationCache(List). The training vectors should be in the same order.- Specified by:
evalin interfaceKernelTrick- Specified by:
evalin classBaseL2Kernel- Parameters:
a- the index of the first training vectorb- the index of the second training vectortrainingSet- the list of training set vectorscache- the double list of cache values generated by this kernel for the given training set- Returns:
- the same kernel evaluation result as
KernelTrick.eval(jsat.linear.Vec, jsat.linear.Vec)
-
eval
public double eval(int a, Vec b, java.util.List<java.lang.Double> qi, java.util.List<? extends Vec> vecs, java.util.List<java.lang.Double> cache)Description copied from interface:KernelTrickComputes the kernel product between one vector in the original list of vectors with that of another vector not from the original list, but had information generated byKernelTrick.getQueryInfo(jsat.linear.Vec).
If the cache input isnull, thenKernelTrick.eval(jsat.linear.Vec, jsat.linear.Vec)will be called directly.- Specified by:
evalin interfaceKernelTrick- Specified by:
evalin classBaseL2Kernel- Parameters:
a- the index of the vector in the cacheb- the other vectorqi- the query information about bvecs- the list of vectors used to build the cachecache- the cache associated with the given list of vectors- Returns:
- the kernel product of the two vectors
-
clone
public RationalQuadraticKernel clone()
- Specified by:
clonein interfaceKernelTrick- Specified by:
clonein classBaseL2Kernel
-
guessC
public static Distribution guessC(DataSet d)
Guess the distribution to use for the C parameter.- Parameters:
d- the data set to get the guess for- Returns:
- the guess for the C parameter
- See Also:
setC(double)
-
normalized
public boolean normalized()
Description copied from interface:KernelTrickThis method indicates if a kernel is a normalized kernel or not. A normalized kernel is one in which k(x,x) = 1 for the same object, and no value greater than 1 can be returned.- Returns:
trueif this is a normalized kernel.falseotherwise.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG