public class RBFKernel extends BaseL2Kernel
Constructor and Description |
---|
RBFKernel()
Creates a new RBF kernel with σ = 1
|
RBFKernel(double sigma)
Creates a new RBF kernel
|
Modifier and Type | Method and Description |
---|---|
RBFKernel |
clone() |
double |
eval(int a,
int b,
List<? extends Vec> trainingSet,
List<Double> cache)
Produces the correct kernel evaluation given the training set and the
cache generated by
KernelTrick.getAccelerationCache(List) . |
double |
eval(int a,
Vec b,
List<Double> qi,
List<? extends Vec> vecs,
List<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 by
KernelTrick.getQueryInfo(jsat.linear.Vec) . |
double |
eval(Vec a,
Vec b)
Evaluate this kernel function for the two given vectors.
|
static double |
gammToSigma(double gamma)
Another common (equivalent) form of the RBF kernel is k(x, y) =
exp(-γ||x-y||2).
|
double |
getSigma() |
static Distribution |
guessSigma(DataSet d)
Guess the distribution to use for the kernel width term
σ in the RBF kernel. |
boolean |
normalized()
This method indicates if a kernel is a normalized kernel or not.
|
void |
setSigma(double sigma)
Sets the sigma parameter, which must be a positive value
|
static double |
sigmaToGamma(double sigma)
Another common (equivalent) form of the RBF kernel is k(x, y) =
exp(-γ||x-y||2).
|
String |
toString()
A descriptive name for the type of KernelFunction
|
addToCache, evalSum, evalSum, getAccelerationCache, getParameter, getParameters, getQueryInfo, getSqrdNorm, getSqrdNorm, getSqrdNorm, supportsAcceleration
public RBFKernel()
public RBFKernel(double sigma)
sigma
- the sigma parameterpublic double eval(Vec a, Vec b)
KernelTrick
eval
in interface KernelTrick
eval
in class BaseL2Kernel
a
- the first vectorb
- the first vectorpublic double eval(int a, int b, List<? extends Vec> trainingSet, List<Double> cache)
KernelTrick
KernelTrick.getAccelerationCache(List)
. The training
vectors should be in the same order.eval
in interface KernelTrick
eval
in class BaseL2Kernel
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 setKernelTrick.eval(jsat.linear.Vec, jsat.linear.Vec)
public double eval(int a, Vec b, List<Double> qi, List<? extends Vec> vecs, List<Double> cache)
KernelTrick
KernelTrick.getQueryInfo(jsat.linear.Vec)
.
null
, then
KernelTrick.eval(jsat.linear.Vec, jsat.linear.Vec)
will be called directly.eval
in interface KernelTrick
eval
in class BaseL2Kernel
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 vectorspublic void setSigma(double sigma)
sigma
- the sigma valuepublic double getSigma()
public String toString()
KernelTrick
toString
in interface KernelTrick
toString
in class Object
public RBFKernel clone()
clone
in interface KernelTrick
clone
in class BaseL2Kernel
public static double sigmaToGamma(double sigma)
sigma
- the value of σpublic static double gammToSigma(double gamma)
gamma
- the value of γpublic static Distribution guessSigma(DataSet d)
σ
in the RBF kernel.d
- the data set to get the guess forpublic boolean normalized()
KernelTrick
true
if this is a normalized kernel. false
otherwise.Copyright © 2017. All rights reserved.