Class CachedKernel
java.lang.Object
weka.classifiers.functions.supportVector.Kernel
weka.classifiers.functions.supportVector.CachedKernel
- All Implemented Interfaces:
Serializable
,CapabilitiesHandler
,OptionHandler
,RevisionHandler
- Direct Known Subclasses:
PolyKernel
,Puk
,RBFKernel
Base class for RBFKernel and PolyKernel that implements a simple LRU.
(least-recently-used) cache if the cache size is set to a value > 0.
Otherwise it uses a full cache.
- Version:
- $Revision: 14512 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz), Shane Legg (shane@intelligenesis.net) (sparse vector code), Stuart Inglis (stuart@reeltwo.com) (sparse vector code), Steven Hugg (hugg@fasterlight.com) (refactored, LRU cache), Bernhard Pfahringer (bernhard@cs.waikato.ac.nz) (full cache)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
buildKernel
(Instances data) builds the kernel with the given data.Returns the tip text for this propertyvoid
clean()
Frees the cache used by the kernel.double
Implements the abstract function of Kernel using the cache.int
Gets the size of the cacheString[]
Gets the current settings of the Kernel.Returns an enumeration describing the available options.int
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.Methods inherited from class weka.classifiers.functions.supportVector.Kernel
debugTipText, forName, getCapabilities, getChecksTurnedOff, getDebug, getDoNotCheckCapabilities, getRevision, globalInfo, makeCopies, makeCopy, setChecksTurnedOff, setDebug, setDoNotCheckCapabilities
-
Constructor Details
-
CachedKernel
public CachedKernel()default constructor - does nothing.
-
-
Method Details
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classKernel
- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options.- Specified by:
setOptions
in interfaceOptionHandler
- Overrides:
setOptions
in classKernel
- Parameters:
options
- the list of options as an array of strings- Throws:
Exception
- if an option is not supported
-
getOptions
Gets the current settings of the Kernel.- Specified by:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classKernel
- Returns:
- an array of strings suitable for passing to setOptions
-
eval
Implements the abstract function of Kernel using the cache. This method uses the evaluate() method to do the actual dot product.- Specified by:
eval
in classKernel
- Parameters:
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)- Returns:
- the result of the kernel function
- Throws:
Exception
- if something goes wrong
-
numEvals
public int numEvals()Returns the number of time Eval has been called. -
numCacheHits
public int numCacheHits()Returns the number of cache hits on dot products.- Specified by:
numCacheHits
in classKernel
- Returns:
- the number of cache hits.
-
clean
public void clean()Frees the cache used by the kernel. -
setCacheSize
public void setCacheSize(int value) Sets the size of the cache to use (a prime number)- Parameters:
value
- the size of the cache
-
getCacheSize
public int getCacheSize()Gets the size of the cache- Returns:
- the cache size
-
cacheSizeTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
buildKernel
builds the kernel with the given data. Initializes the kernel cache. The actual size of the cache in bytes is (64 * cacheSize).- Overrides:
buildKernel
in classKernel
- Parameters:
data
- the data to base the kernel on- Throws:
Exception
- if something goes wrong
-