public abstract class CachedKernel extends Kernel
Modifier and Type | Field and Description |
---|---|
protected int |
m_cacheHits
Counts the number of kernel cache hits.
|
protected int |
m_cacheSize
The size of the cache (a prime number)
|
protected int |
m_cacheSlots
number of cache slots in an entry
|
protected int |
m_kernelEvals
Counts the number of kernel evaluations.
|
protected double[][] |
m_kernelMatrix
The kernel matrix if full cache is used (i.e. size is set to 0)
|
protected long[] |
m_keys
Kernel cache (keys)
|
protected int |
m_numInsts
The number of instance in the dataset
|
protected double[] |
m_storage
Kernel cache
|
m_ChecksTurnedOff, m_data, m_Debug
Modifier | Constructor and Description |
---|---|
|
CachedKernel()
default constructor - does nothing.
|
protected |
CachedKernel(Instances data,
int cacheSize)
Initializes the kernel cache.
|
Modifier and Type | Method and Description |
---|---|
void |
buildKernel(Instances data)
builds the kernel with the given data.
|
java.lang.String |
cacheSizeTipText()
Returns the tip text for this property
|
void |
clean()
Frees the cache used by the kernel.
|
protected double |
dotProd(Instance inst1,
Instance inst2)
Calculates a dot product between two instances
|
double |
eval(int id1,
int id2,
Instance inst1)
Implements the abstract function of Kernel using the cache.
|
protected abstract double |
evaluate(int id1,
int id2,
Instance inst1)
This method is overridden in subclasses to implement specific kernels.
|
int |
getCacheSize()
Gets the size of the cache
|
java.lang.String[] |
getOptions()
Gets the current settings of the Kernel.
|
protected void |
initVars(Instances data)
initializes variables etc.
|
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
int |
numCacheHits()
Returns the number of cache hits on dot products.
|
int |
numEvals()
Returns the number of time Eval has been called.
|
void |
setCacheSize(int value)
Sets the size of the cache to use (a prime number)
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
checksTurnedOffTipText, debugTipText, forName, getChecksTurnedOff, getDebug, globalInfo, makeCopies, makeCopy, setChecksTurnedOff, setDebug
protected int m_kernelEvals
protected int m_cacheHits
protected int m_cacheSize
protected double[] m_storage
protected long[] m_keys
protected double[][] m_kernelMatrix
protected int m_numInsts
protected int m_cacheSlots
public CachedKernel()
protected CachedKernel(Instances data, int cacheSize) throws java.lang.Exception
data
- the data to usecacheSize
- the cache sizejava.lang.Exception
- if something goes wrongpublic java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Kernel
public void setOptions(java.lang.String[] options) throws java.lang.Exception
setOptions
in interface OptionHandler
setOptions
in class Kernel
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class Kernel
protected abstract double evaluate(int id1, int id2, Instance inst1) throws java.lang.Exception
id1
- the index of instance 1id2
- the index of instance 2inst1
- the instance 1 objectjava.lang.Exception
- if something goes wrongpublic double eval(int id1, int id2, Instance inst1) throws java.lang.Exception
eval
in class Kernel
id1
- the index of the first instance in the datasetid2
- the index of the second instance in the datasetinst1
- the instance corresponding to id1 (used if id1 == -1)java.lang.Exception
- if something goes wrongpublic int numEvals()
public int numCacheHits()
numCacheHits
in class Kernel
protected final double dotProd(Instance inst1, Instance inst2) throws java.lang.Exception
inst1
- the first instanceinst2
- the second instancejava.lang.Exception
- if an error occurspublic void setCacheSize(int value)
value
- the size of the cachepublic int getCacheSize()
public java.lang.String cacheSizeTipText()
protected void initVars(Instances data)
public void buildKernel(Instances data) throws java.lang.Exception
buildKernel
in class Kernel
data
- the data to base the kernel onjava.lang.Exception
- if something goes wrong