public abstract class SupportVectorLearner extends Object implements Serializable
kernel
to project the data into a different space. The
final set of vectors used may or may not be sparse. It does not necessarily
have to be a Support Vector machine.
Modifier and Type | Class and Description |
---|---|
static class |
SupportVectorLearner.CacheMode
Determines how the final kernel values are cached.
|
Modifier and Type | Field and Description |
---|---|
protected List<Double> |
accelCache
Kernel evaluation acceleration cache
|
protected double[] |
alphas
The array of coefficients associated with each support vector.
|
protected int |
cacheEvictions |
protected int |
evalCount |
protected List<Vec> |
vecs
The array of vectors.
|
Modifier | Constructor and Description |
---|---|
protected |
SupportVectorLearner()
This constructor is meant manly for Serialization to work.
|
|
SupportVectorLearner(KernelTrick kernel,
SupportVectorLearner.CacheMode cacheMode)
Creates a new Support Vector Learner
|
|
SupportVectorLearner(SupportVectorLearner toCopy)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
accessingRow(int r)
This method allows the caller to hint that they are about to access many
kernel values for a specific row.
|
SupportVectorLearner.CacheMode |
getCacheMode()
Returns the current caching mode in use
|
int |
getCacheValue()
Returns the current cache value
|
KernelTrick |
getKernel() |
protected double |
k(int a,
int b)
Internal kernel eval source.
|
protected double |
kEval(int a,
int b)
Performs a kernel evaluation of the a'th and b'th vectors in the
vecs array. |
protected double |
kEval(Vec a,
Vec b)
Performs a kernel evaluation of the product between two vectors directly.
|
protected double |
kEvalSum(Vec y)
Performs a summation of the form
∑ αi k(xi, y) for each support vector and associated alpha value currently stored in the support vector machine. |
protected void |
setAlphas(double[] alphas)
Sets the final set of alphas, and indicates that the final accelerating
structures (if available) should be constructed for performing kernel
evaluations against unseen vectors.
|
void |
setCacheMode(SupportVectorLearner.CacheMode cacheMode)
Calling this sets the method of caching that will be used.
|
void |
setCacheSize(long N,
long bytes)
Sets the
cache value to one that will use the
specified amount of memory. |
void |
setCacheValue(int cacheValue)
Sets the cache value, which may be interpreted differently by different
caching schemes.
|
void |
setKernel(KernelTrick kernel)
Sets the kernel trick to use
|
protected void |
sparsify()
Sparsifies the SVM by removing the vectors with α = 0 from the
dataset.
|
protected List<Vec> vecs
protected double[] alphas
setAlphas(double[])
should be
called with a reference to itself or the array where the final alphas are
stored. This will initialized any accelerating structures so that
kEvalSum(jsat.linear.Vec)
can be called.protected int evalCount
protected int cacheEvictions
protected SupportVectorLearner()
public SupportVectorLearner(KernelTrick kernel, SupportVectorLearner.CacheMode cacheMode)
kernel
- the kernel trick to usecacheMode
- the kernel caching method to usepublic SupportVectorLearner(SupportVectorLearner toCopy)
toCopy
- the object to copyprotected void setAlphas(double[] alphas)
alphas
- the final array of alphaspublic void setKernel(KernelTrick kernel)
kernel
- the kernel trick to usepublic void setCacheValue(int cacheValue)
SupportVectorLearner.CacheMode.ROWS
, where the value
indicates how many rows will be cached.cacheValue
- the cache value to be usedpublic void setCacheSize(long N, long bytes)
cache value
to one that will use the
specified amount of memory. If the amount of memory specified is great
enough, this method will automatically set the
cache mode
to SupportVectorLearner.CacheMode.FULL
.N
- the number of data pointsbytes
- the number of bytes of memory to make the cachepublic int getCacheValue()
public SupportVectorLearner.CacheMode getCacheMode()
public void setCacheMode(SupportVectorLearner.CacheMode cacheMode)
null
to
deinitialize the caches.cacheMode
- public KernelTrick getKernel()
protected double kEvalSum(Vec y)
setAlphas(double[])
before calling this, but kernel evaluations
may be slower if this is not done.y
- the vector to perform the kernel product sum againstprotected double kEval(Vec a, Vec b)
evalCount
a
- the first vectorb
- the second vectorprotected double kEval(int a, int b)
vecs
array.a
- the first vector indexb
- the second vector indexprotected void accessingRow(int r)
r
- the row to cache explicitly to avoid LRU overhead. Or a negative
value to indicate that we are done with any specific row.protected double k(int a, int b)
a
- the first vector indexb
- the second vector indexprotected void sparsify()
Copyright © 2017. All rights reserved.