public class GeneralRBFKernel extends DistanceMetricBasedKernel
RBFKernel
to arbitrary
distance metrics
, and is of the form
exp(-d(x, y)2/(2 σ
2
)). So long as the distance metric is valid, the resulting kernel trick
will be a valid kernel. EuclideanDistance
is used, then this becomes equivalent to the
RBFKernel
. KernelTrick
has no concept of training - the
distance metric can not require training either. A pre-trained metric can
be admissible thought.d
Constructor and Description |
---|
GeneralRBFKernel(DistanceMetric d,
double sigma)
Creates a new Generic RBF Kernel
|
Modifier and Type | Method and Description |
---|---|
KernelTrick |
clone() |
double |
eval(int a,
int b,
List<? extends Vec> vecs,
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.
|
double |
getSigma() |
Distribution |
guessSigma(DataSet d)
Guess the distribution to use for the kernel width term
σ in the General RBF kernel. |
static Distribution |
guessSigma(DataSet d,
DistanceMetric dist)
Guess the distribution to use for the kernel width term
σ in the General RBF kernel. |
boolean |
normalized()
This method indicates if a kernel is a normalized kernel or not.
|
void |
setSigma(double sigma)
Sets the kernel width parameter, which must be a positive value.
|
addToCache, evalSum, evalSum, getAccelerationCache, getParameter, getParameters, getQueryInfo, supportsAcceleration
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toString
public GeneralRBFKernel(DistanceMetric d, double sigma)
d
- the distance metric to usesigma
- the standard deviation to usepublic void setSigma(double sigma)
sigma
- the sigma valuepublic double getSigma()
public KernelTrick clone()
clone
in interface KernelTrick
clone
in class DistanceMetricBasedKernel
public double eval(Vec a, Vec b)
KernelTrick
a
- the first vectorb
- the first vectorpublic 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.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 double eval(int a, int b, List<? extends Vec> vecs, List<Double> cache)
KernelTrick
KernelTrick.getAccelerationCache(List)
. The training
vectors should be in the same order.a
- the index of the first training vectorb
- the index of the second training vectorvecs
- 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 Distribution guessSigma(DataSet d)
σ
in the General RBF kernel.d
- the data set to get the guess forpublic static Distribution guessSigma(DataSet d, DistanceMetric dist)
σ
in the General RBF kernel.d
- the data set to get the guess fordist
- the distance metric to assume is being used in the kernelpublic boolean normalized()
KernelTrick
true
if this is a normalized kernel. false
otherwise.Copyright © 2017. All rights reserved.