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.
|
protected long[] |
m_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.
|
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
|
String[] |
getOptions()
Gets the current settings of the Kernel.
|
protected void |
initVars(Instances data)
initializes variables etc.
|
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(String[] options)
Parses a given list of options.
|
checksTurnedOffTipText, debugTipText, forName, getCapabilities, getChecksTurnedOff, getDebug, getRevision, globalInfo, makeCopies, makeCopy, setChecksTurnedOff, setDebugprotected 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 Enumeration listOptions()
listOptions in interface OptionHandlerlistOptions in class Kernelpublic void setOptions(String[] options) throws Exception
setOptions in interface OptionHandlersetOptions in class Kerneloptions - the list of options as an array of stringsException - if an option is not supportedpublic String[] getOptions()
getOptions in interface OptionHandlergetOptions in class Kernelprotected abstract double evaluate(int id1,
int id2,
Instance inst1)
throws Exception
id1 - the index of instance 1id2 - the index of instance 2inst1 - the instance 1 objectException - if something goes wrongpublic double eval(int id1,
int id2,
Instance inst1)
throws Exception
eval in class Kernelid1 - 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)Exception - if something goes wrongpublic int numEvals()
public int numCacheHits()
numCacheHits in class Kernelprotected final double dotProd(Instance inst1, Instance inst2) throws Exception
inst1 - the first instanceinst2 - the second instanceException - if an error occurspublic void setCacheSize(int value)
value - the size of the cachepublic int getCacheSize()
public String cacheSizeTipText()
protected void initVars(Instances data)
public void buildKernel(Instances data) throws Exception
buildKernel in class Kerneldata - the data to base the kernel onException - if something goes wrongCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.