Package weka.classifiers.lazy
Class LWL
java.lang.Object
weka.classifiers.AbstractClassifier
weka.classifiers.SingleClassifierEnhancer
weka.classifiers.lazy.LWL
- All Implemented Interfaces:
Serializable
,Cloneable
,Classifier
,UpdateableClassifier
,BatchPredictor
,CapabilitiesHandler
,CapabilitiesIgnorer
,CommandlineRunnable
,OptionHandler
,RevisionHandler
,TechnicalInformationHandler
,WeightedInstancesHandler
public class LWL
extends SingleClassifierEnhancer
implements UpdateableClassifier, WeightedInstancesHandler, TechnicalInformationHandler
Locally weighted learning. Uses an instance-based algorithm to assign instance weights which are then used by a specified WeightedInstancesHandler.
Can do classification (e.g. using naive Bayes) or regression (e.g. using linear regression).
For more info, see
Eibe Frank, Mark Hall, Bernhard Pfahringer: Locally Weighted Naive Bayes. In: 19th Conference in Uncertainty in Artificial Intelligence, 249-256, 2003.
C. Atkeson, A. Moore, S. Schaal (1996). Locally weighted learning. AI Review.. BibTeX:
Can do classification (e.g. using naive Bayes) or regression (e.g. using linear regression).
For more info, see
Eibe Frank, Mark Hall, Bernhard Pfahringer: Locally Weighted Naive Bayes. In: 19th Conference in Uncertainty in Artificial Intelligence, 249-256, 2003.
C. Atkeson, A. Moore, S. Schaal (1996). Locally weighted learning. AI Review.. BibTeX:
@inproceedings{Frank2003, author = {Eibe Frank and Mark Hall and Bernhard Pfahringer}, booktitle = {19th Conference in Uncertainty in Artificial Intelligence}, pages = {249-256}, publisher = {Morgan Kaufmann}, title = {Locally Weighted Naive Bayes}, year = {2003} } @article{Atkeson1996, author = {C. Atkeson and A. Moore and S. Schaal}, journal = {AI Review}, title = {Locally weighted learning}, year = {1996} }Valid options are:
-A The nearest neighbour search algorithm to use (default: weka.core.neighboursearch.LinearNNSearch).
-K <number of neighbours> Set the number of neighbours used to set the kernel bandwidth. (default all)
-U <number of weighting method> Set the weighting kernel shape to use. 0=Linear, 1=Epanechnikov, 2=Tricube, 3=Inverse, 4=Gaussian. (default 0 = Linear)
-D If set, classifier is run in debug mode and may output additional info to the console
-W Full name of base classifier. (default: weka.classifiers.trees.DecisionStump)
Options specific to classifier weka.classifiers.trees.DecisionStump:
-D If set, classifier is run in debug mode and may output additional info to the console
- Version:
- $Revision: 10141 $
- Author:
- Len Trigg (trigg@cs.waikato.ac.nz), Eibe Frank (eibe@cs.waikato.ac.nz), Ashraf M. Kibriya (amk14[at-the-rate]cs[dot]waikato[dot]ac[dot]nz)
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
The available kernel weighting methods.static final int
Fields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
buildClassifier
(Instances instances) Generates the classifier.double[]
distributionForInstance
(Instance instance) Calculates the class membership probabilities for the given test instance.Returns an enumeration of the additional measure names produced by the neighbour search algorithm.Returns default capabilities of the classifier.int
getKNN()
Gets the number of neighbours used for kernel bandwidth setting.double
getMeasure
(String additionalMeasureName) Returns the value of the named measure from the neighbour search algorithm.Returns the current nearestNeighbourSearch algorithm in use.String[]
Gets the current settings of the classifier.Returns the revision string.Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.int
Gets the kernel weighting method to use.Returns a string describing classifier.Returns the tip text for this property.Returns an enumeration describing the available options.static void
Main method for testing this class.Returns the tip text for this property.void
setKNN
(int knn) Sets the number of neighbours used for kernel bandwidth setting.void
setNearestNeighbourSearchAlgorithm
(NearestNeighbourSearch nearestNeighbourSearchAlgorithm) Sets the nearestNeighbourSearch algorithm to be used for finding nearest neighbour(s).void
setOptions
(String[] options) Parses a given list of options.void
setWeightingKernel
(int kernel) Sets the kernel weighting method to use.toString()
Returns a description of this classifier.void
updateClassifier
(Instance instance) Adds the supplied instance to the training set.Returns the tip text for this property.Methods inherited from class weka.classifiers.SingleClassifierEnhancer
classifierTipText, getClassifier, postExecution, preExecution, setClassifier
Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
Field Details
-
LINEAR
public static final int LINEARThe available kernel weighting methods.- See Also:
-
EPANECHNIKOV
public static final int EPANECHNIKOV- See Also:
-
TRICUBE
public static final int TRICUBE- See Also:
-
INVERSE
public static final int INVERSE- See Also:
-
GAUSS
public static final int GAUSS- See Also:
-
CONSTANT
public static final int CONSTANT- See Also:
-
-
Constructor Details
-
LWL
public LWL()Constructor.
-
-
Method Details
-
globalInfo
Returns a string describing classifier.- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
getTechnicalInformation
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.- Specified by:
getTechnicalInformation
in interfaceTechnicalInformationHandler
- Returns:
- the technical information about this class
-
enumerateMeasures
Returns an enumeration of the additional measure names produced by the neighbour search algorithm.- Returns:
- an enumeration of the measure names
-
getMeasure
Returns the value of the named measure from the neighbour search algorithm.- Parameters:
additionalMeasureName
- the name of the measure to query for its value- Returns:
- the value of the named measure
- Throws:
IllegalArgumentException
- if the named measure is not supported
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classSingleClassifierEnhancer
- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options. Valid options are:-A The nearest neighbour search algorithm to use (default: weka.core.neighboursearch.LinearNNSearch).
-K <number of neighbours> Set the number of neighbours used to set the kernel bandwidth. (default all)
-U <number of weighting method> Set the weighting kernel shape to use. 0=Linear, 1=Epanechnikov, 2=Tricube, 3=Inverse, 4=Gaussian. (default 0 = Linear)
-D If set, classifier is run in debug mode and may output additional info to the console
-W Full name of base classifier. (default: weka.classifiers.trees.DecisionStump)
Options specific to classifier weka.classifiers.trees.DecisionStump:
-D If set, classifier is run in debug mode and may output additional info to the console
- Specified by:
setOptions
in interfaceOptionHandler
- Overrides:
setOptions
in classSingleClassifierEnhancer
- 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 classifier.- Specified by:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classSingleClassifierEnhancer
- Returns:
- an array of strings suitable for passing to setOptions
-
KNNTipText
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setKNN
public void setKNN(int knn) Sets the number of neighbours used for kernel bandwidth setting. The bandwidth is taken as the distance to the kth neighbour.- Parameters:
knn
- the number of neighbours included inside the kernel bandwidth, or 0 to specify using all neighbors.
-
getKNN
public int getKNN()Gets the number of neighbours used for kernel bandwidth setting. The bandwidth is taken as the distance to the kth neighbour.- Returns:
- the number of neighbours included inside the kernel bandwidth, or 0 for all neighbours
-
weightingKernelTipText
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setWeightingKernel
public void setWeightingKernel(int kernel) Sets the kernel weighting method to use. Must be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT, other values are ignored.- Parameters:
kernel
- the new kernel method to use. Must be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT.
-
getWeightingKernel
public int getWeightingKernel()Gets the kernel weighting method to use.- Returns:
- the new kernel method to use. Will be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT.
-
nearestNeighbourSearchAlgorithmTipText
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getNearestNeighbourSearchAlgorithm
Returns the current nearestNeighbourSearch algorithm in use.- Returns:
- the NearestNeighbourSearch algorithm currently in use.
-
setNearestNeighbourSearchAlgorithm
public void setNearestNeighbourSearchAlgorithm(NearestNeighbourSearch nearestNeighbourSearchAlgorithm) Sets the nearestNeighbourSearch algorithm to be used for finding nearest neighbour(s).- Parameters:
nearestNeighbourSearchAlgorithm
- - The NearestNeighbourSearch class.
-
getCapabilities
Returns default capabilities of the classifier.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Specified by:
getCapabilities
in interfaceClassifier
- Overrides:
getCapabilities
in classSingleClassifierEnhancer
- Returns:
- the capabilities of this classifier
- See Also:
-
buildClassifier
Generates the classifier.- Specified by:
buildClassifier
in interfaceClassifier
- Parameters:
instances
- set of instances serving as training data- Throws:
Exception
- if the classifier has not been generated successfully
-
updateClassifier
Adds the supplied instance to the training set.- Specified by:
updateClassifier
in interfaceUpdateableClassifier
- Parameters:
instance
- the instance to add- Throws:
Exception
- if instance could not be incorporated successfully
-
distributionForInstance
Calculates the class membership probabilities for the given test instance.- Specified by:
distributionForInstance
in interfaceClassifier
- Overrides:
distributionForInstance
in classAbstractClassifier
- Parameters:
instance
- the instance to be classified- Returns:
- preedicted class probability distribution
- Throws:
Exception
- if distribution can't be computed successfully
-
toString
Returns a description of this classifier. -
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classAbstractClassifier
- Returns:
- the revision
-
main
Main method for testing this class.- Parameters:
argv
- the options
-