public abstract class DistanceMetricBasedKernel extends Object implements KernelTrick
DistanceMetric
. This will pre-implement most of the methods of
the KernelTrick interface, including using the distance acceleration of the
metric (if supported) when appropriate.Modifier and Type | Field and Description |
---|---|
protected DistanceMetric |
d
the distance metric to use for the Kernel
|
Constructor and Description |
---|
DistanceMetricBasedKernel(DistanceMetric d)
Creates a new distance based kerenel
|
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.
|
abstract KernelTrick |
clone() |
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.
|
Parameter |
getParameter(String paramName)
Returns the parameter with the given name.
|
List<Parameter> |
getParameters()
Returns the list of parameters that can be altered for this learner.
|
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
KernelTrick.getAccelerationCache(java.util.List) . |
boolean |
supportsAcceleration()
Indicates if this kernel supports building an acceleration cache
using the
KernelTrick.getAccelerationCache(List) and associated
cache accelerated methods. |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
eval, eval, eval, normalized, toString
protected DistanceMetric d
public DistanceMetricBasedKernel(DistanceMetric d)
d
- the distance metric to usepublic abstract KernelTrick clone()
clone
in interface KernelTrick
clone
in class Object
public boolean supportsAcceleration()
KernelTrick
KernelTrick.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 KernelTrick.eval(int, Vec, List, List, List)
and KernelTrick.eval(int, int, List, List)
to perform kernel products.supportsAcceleration
in interface KernelTrick
true
if cache acceleration is supported for this kernel,
false
otherwise.public List<Double> getAccelerationCache(List<? extends Vec> trainingSet)
KernelTrick
null
will
be returned.getAccelerationCache
in interface KernelTrick
trainingSet
- the list of training set vectorspublic List<Double> getQueryInfo(Vec q)
KernelTrick
KernelTrick.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.getQueryInfo
in interface KernelTrick
q
- the query point to generate cache information forpublic void addToCache(Vec newVec, List<Double> cache)
KernelTrick
KernelTrick.getAccelerationCache(java.util.List)
addToCache
in interface KernelTrick
newVec
- the new vector to add to the cache valuescache
- the original list of cache values to add topublic double evalSum(List<? extends Vec> finalSet, List<Double> cache, double[] alpha, Vec y, int start, int end)
KernelTrick
evalSum
in interface KernelTrick
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 frompublic double evalSum(List<? extends Vec> finalSet, List<Double> cache, double[] alpha, Vec y, List<Double> qi, int start, int end)
KernelTrick
evalSum
in interface KernelTrick
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 frompublic List<Parameter> getParameters()
Parameterized
getParameters
in interface Parameterized
public Parameter getParameter(String paramName)
Parameterized
getParameter
in interface Parameterized
paramName
- the name of the parameter to obtainCopyright © 2017. All rights reserved.