public interface KernelTrick extends Parameterized, Cloneable, Serializable
parameterized
so that the
values of the kernel can be exposed by the algorithm that makes use of these
parameters. To avoid conflicts in parameter names, the parameters of a
KernelTrick should be of the form:Modifier and Type | Method and Description |
---|---|
void |
addToCache(Vec newVec,
List<Double> cache)
Appends the new cache values for the given vector to the list of cache
values.
|
KernelTrick |
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
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
getQueryInfo(jsat.linear.Vec) . |
double |
eval(Vec a,
Vec b)
Evaluate this kernel function for the two given vectors.
|
double |
evalSum(List<? extends Vec> finalSet,
List<Double> cache,
double[] alpha,
Vec y,
int start,
int end)
Performs an efficient summation of kernel products of the form
∑ αi k(xi, y) where x are the final set of vectors, and α the associated scalar multipliers |
double |
evalSum(List<? extends Vec> finalSet,
List<Double> cache,
double[] alpha,
Vec y,
List<Double> qi,
int start,
int end)
Performs an efficient summation of kernel products of the form
∑ αi k(xi, y) where x are the final set of vectors, and α the associated scalar multipliers |
List<Double> |
getAccelerationCache(List<? extends Vec> trainingSet)
Creates a new list cache values from a given list of training set
vectors.
|
List<Double> |
getQueryInfo(Vec q)
Pre computes query information that would have be generated if the query
was a member of the original list of vectors when calling
getAccelerationCache(java.util.List) . |
boolean |
normalized()
This method indicates if a kernel is a normalized kernel or not.
|
boolean |
supportsAcceleration()
Indicates if this kernel supports building an acceleration cache
using the
getAccelerationCache(List) and associated
cache accelerated methods. |
String |
toString()
A descriptive name for the type of KernelFunction
|
getParameter, getParameters
double eval(Vec a, Vec b)
a
- the first vectorb
- the first vectorString toString()
KernelTrick clone()
boolean supportsAcceleration()
getAccelerationCache(List)
and associated
cache accelerated methods. By default this method will return
false
. If true
, then a cache can be obtained from this
matrix and used in conjunction with eval(int, Vec, List, List, List)
and eval(int, int, List, List)
to perform kernel products.true
if cache acceleration is supported for this kernel,
false
otherwise.List<Double> getAccelerationCache(List<? extends Vec> trainingSet)
null
will
be returned.trainingSet
- the list of training set vectorsList<Double> getQueryInfo(Vec q)
getAccelerationCache(java.util.List)
. This can then be used if
a large number of kernel computations are going to be done against
points in the original set for a point that is outside the original space.
null
will be
returned.q
- the query point to generate cache information forvoid addToCache(Vec newVec, List<Double> cache)
getAccelerationCache(java.util.List)
newVec
- the new vector to add to the cache valuescache
- the original list of cache values to add todouble eval(int a, Vec b, List<Double> qi, List<? extends Vec> vecs, List<Double> cache)
getQueryInfo(jsat.linear.Vec)
.
null
, then
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 vectorsdouble eval(int a, int b, List<? extends Vec> trainingSet, List<Double> cache)
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 vectortrainingSet
- the list of training set vectorscache
- the double list of cache values generated by this kernel
for the given training seteval(jsat.linear.Vec, jsat.linear.Vec)
double evalSum(List<? extends Vec> finalSet, List<Double> cache, double[] alpha, Vec y, int start, int end)
finalSet
- the final set of vectorscache
- the cache associated with the final set of vectorsalpha
- the coefficients associated with each vectory
- the vector to perform the summed kernel products againststart
- the starting index (inclusive) to sum fromend
- the ending index (exclusive) to sum fromdouble evalSum(List<? extends Vec> finalSet, List<Double> cache, double[] alpha, Vec y, List<Double> qi, int start, int end)
finalSet
- the final set of vectorscache
- the cache associated with the final set of vectorsalpha
- the coefficients associated with each vectory
- the vector to perform the summed kernel products againstqi
- the query information about ystart
- the starting index (inclusive) to sum fromend
- the ending index (exclusive) to sum fromboolean normalized()
true
if this is a normalized kernel. false
otherwise.Copyright © 2017. All rights reserved.