public class LWL extends SingleClassifierEnhancer implements UpdateableClassifier, WeightedInstancesHandler, TechnicalInformationHandler
@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
Modifier and Type | Field and Description |
---|---|
protected static int |
CONSTANT |
protected static int |
EPANECHNIKOV |
protected static int |
GAUSS |
protected static int |
INVERSE |
protected static int |
LINEAR
The available kernel weighting methods.
|
protected int |
m_kNN
The number of neighbours used to select the kernel bandwidth.
|
protected NearestNeighbourSearch |
m_NNSearch
The nearest neighbour search algorithm to use.
|
protected Instances |
m_Train
The training instances used for classification.
|
protected boolean |
m_UseAllK
True if m_kNN should be set to all instances.
|
protected int |
m_WeightKernel
The weighting kernel method currently selected.
|
protected Classifier |
m_ZeroR
a ZeroR model in case no model can be built from the data.
|
protected static int |
TRICUBE |
m_Classifier
m_Debug
Constructor and Description |
---|
LWL()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
buildClassifier(Instances instances)
Generates the classifier.
|
protected String |
defaultClassifierString()
String describing default classifier.
|
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance.
|
Enumeration |
enumerateMeasures()
Returns an enumeration of the additional measure names
produced by the neighbour search algorithm.
|
Capabilities |
getCapabilities()
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.
|
NearestNeighbourSearch |
getNearestNeighbourSearchAlgorithm()
Returns the current nearestNeighbourSearch algorithm in use.
|
String[] |
getOptions()
Gets the current settings of the classifier.
|
String |
getRevision()
Returns the revision string.
|
TechnicalInformation |
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.
|
int |
getWeightingKernel()
Gets the kernel weighting method to use.
|
String |
globalInfo()
Returns a string describing classifier.
|
String |
KNNTipText()
Returns the tip text for this property.
|
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(String[] argv)
Main method for testing this class.
|
String |
nearestNeighbourSearchAlgorithmTipText()
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.
|
String |
toString()
Returns a description of this classifier.
|
void |
updateClassifier(Instance instance)
Adds the supplied instance to the training set.
|
String |
weightingKernelTipText()
Returns the tip text for this property.
|
classifierTipText, getClassifier, getClassifierSpec, setClassifier
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, runClassifier, setDebug
protected Instances m_Train
protected int m_kNN
protected int m_WeightKernel
protected boolean m_UseAllK
protected NearestNeighbourSearch m_NNSearch
protected static final int LINEAR
protected static final int EPANECHNIKOV
protected static final int TRICUBE
protected static final int INVERSE
protected static final int GAUSS
protected static final int CONSTANT
protected Classifier m_ZeroR
public String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
protected String defaultClassifierString()
defaultClassifierString
in class SingleClassifierEnhancer
public Enumeration enumerateMeasures()
public double getMeasure(String additionalMeasureName)
additionalMeasureName
- the name of the measure to query for its valueIllegalArgumentException
- if the named measure is not supportedpublic Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class SingleClassifierEnhancer
public void setOptions(String[] options) throws Exception
-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
setOptions
in interface OptionHandler
setOptions
in class SingleClassifierEnhancer
options
- the list of options as an array of stringsException
- if an option is not supportedpublic String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class SingleClassifierEnhancer
public String KNNTipText()
public void setKNN(int knn)
knn
- the number of neighbours included inside the kernel
bandwidth, or 0 to specify using all neighbors.public int getKNN()
public String weightingKernelTipText()
public void setWeightingKernel(int kernel)
kernel
- the new kernel method to use. Must be one of LINEAR,
EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT.public int getWeightingKernel()
public String nearestNeighbourSearchAlgorithmTipText()
public NearestNeighbourSearch getNearestNeighbourSearchAlgorithm()
public void setNearestNeighbourSearchAlgorithm(NearestNeighbourSearch nearestNeighbourSearchAlgorithm)
nearestNeighbourSearchAlgorithm
- - The NearestNeighbourSearch class.public Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class SingleClassifierEnhancer
Capabilities
public void buildClassifier(Instances instances) throws Exception
buildClassifier
in class Classifier
instances
- set of instances serving as training dataException
- if the classifier has not been generated successfullypublic void updateClassifier(Instance instance) throws Exception
updateClassifier
in interface UpdateableClassifier
instance
- the instance to addException
- if instance could not be incorporated
successfullypublic double[] distributionForInstance(Instance instance) throws Exception
distributionForInstance
in class Classifier
instance
- the instance to be classifiedException
- if distribution can't be computed successfullypublic String toString()
public String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class Classifier
public static void main(String[] argv)
argv
- the optionsCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.