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 |
---|---|
static int |
CONSTANT |
static int |
EPANECHNIKOV |
static int |
GAUSS |
static int |
INVERSE |
static int |
LINEAR
The available kernel weighting methods.
|
static int |
TRICUBE |
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
Constructor and Description |
---|
LWL()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
buildClassifier(Instances instances)
Generates the classifier.
|
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test instance.
|
java.util.Enumeration<java.lang.String> |
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(java.lang.String additionalMeasureName)
Returns the value of the named measure from the
neighbour search algorithm.
|
NearestNeighbourSearch |
getNearestNeighbourSearchAlgorithm()
Returns the current nearestNeighbourSearch algorithm in use.
|
java.lang.String[] |
getOptions()
Gets the current settings of the classifier.
|
java.lang.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.
|
java.lang.String |
globalInfo()
Returns a string describing classifier.
|
java.lang.String |
KNNTipText()
Returns the tip text for this property.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(java.lang.String[] argv)
Main method for testing this class.
|
java.lang.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(java.lang.String[] options)
Parses a given list of options.
|
void |
setWeightingKernel(int kernel)
Sets the kernel weighting method to use.
|
java.lang.String |
toString()
Returns a description of this classifier.
|
void |
updateClassifier(Instance instance)
Adds the supplied instance to the training set.
|
java.lang.String |
weightingKernelTipText()
Returns the tip text for this property.
|
classifierTipText, getClassifier, postExecution, preExecution, setClassifier
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
makeCopy
public static final int LINEAR
public static final int EPANECHNIKOV
public static final int TRICUBE
public static final int INVERSE
public static final int GAUSS
public static final int CONSTANT
public java.lang.String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public java.util.Enumeration<java.lang.String> enumerateMeasures()
public double getMeasure(java.lang.String additionalMeasureName)
additionalMeasureName
- the name of the measure to query for its valuejava.lang.IllegalArgumentException
- if the named measure is not supportedpublic java.util.Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
listOptions
in class SingleClassifierEnhancer
public void setOptions(java.lang.String[] options) throws java.lang.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 stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class SingleClassifierEnhancer
public java.lang.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 java.lang.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 java.lang.String nearestNeighbourSearchAlgorithmTipText()
public NearestNeighbourSearch getNearestNeighbourSearchAlgorithm()
public void setNearestNeighbourSearchAlgorithm(NearestNeighbourSearch nearestNeighbourSearchAlgorithm)
nearestNeighbourSearchAlgorithm
- - The NearestNeighbourSearch class.public Capabilities getCapabilities()
getCapabilities
in interface Classifier
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class SingleClassifierEnhancer
Capabilities
public void buildClassifier(Instances instances) throws java.lang.Exception
buildClassifier
in interface Classifier
instances
- set of instances serving as training datajava.lang.Exception
- if the classifier has not been generated successfullypublic void updateClassifier(Instance instance) throws java.lang.Exception
updateClassifier
in interface UpdateableClassifier
instance
- the instance to addjava.lang.Exception
- if instance could not be incorporated
successfullypublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in interface Classifier
distributionForInstance
in class AbstractClassifier
instance
- the instance to be classifiedjava.lang.Exception
- if distribution can't be computed successfullypublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClassifier
public static void main(java.lang.String[] argv)
argv
- the options