All Packages Class Hierarchy This Package Previous Next Index WEKA's home
Class weka.classifiers.lazy.LWL
java.lang.Object
|
+----weka.classifiers.Classifier
|
+----weka.classifiers.DistributionClassifier
|
+----weka.classifiers.lazy.LWL
- public class LWL
- extends DistributionClassifier
- implements OptionHandler, UpdateableClassifier, WeightedInstancesHandler
Locally-weighted learning. Uses an instance-based algorithm to
assign instance weights which are then used by a specified
WeightedInstancesHandler. A good choice for classification is
NaiveBayes. LinearRegression is suitable for regression problems.
For more information, see
Eibe Frank, Mark Hall, and Bernhard Pfahringer (2003). Locally
Weighted Naive Bayes. Working Paper 04/03, Department of Computer
Science, University of Waikato.
Atkeson, C., A. Moore, and S. Schaal (1996) Locally weighted
learning
download
postscript.
Valid options are:
-D
Produce debugging output.
-K num
Set the number of neighbours used for setting kernel bandwidth.
(default all)
-W num
Set the weighting kernel shape to use. 1 = Inverse, 2 = Gaussian.
(default 0 = Linear)
-B classname
Specify the full class name of a base classifier (which needs
to be a WeightedInstancesHandler) (required).
- Version:
- $Revision: 1.6 $
- Author:
- Len Trigg (trigg@cs.waikato.ac.nz)
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
LWL()
-
buildClassifier(Instances)
- Generates the classifier.
distributionForInstance(Instance)
- Calculates the class membership probabilities for the given test instance.
getClassifier()
- Get the classifier used as the classifier
getDebug()
- SGts whether debugging output should be produced
getKNN()
- Gets the number of neighbours used for kernel bandwidth setting.
getOptions()
- Gets the current settings of the classifier.
getWeightingKernel()
- Gets the kernel weighting method to use.
listOptions()
- Returns an enumeration describing the available options.
main(String[])
- Main method for testing this class.
setClassifier(Classifier)
- Set the classifier for locally weighted learning.
setDebug(boolean)
- Sets whether debugging output should be produced
setKNN(int)
- Sets the number of neighbours used for kernel bandwidth setting.
setOptions(String[])
- Parses a given list of options.
setWeightingKernel(int)
- Sets the kernel weighting method to use.
toString()
- Returns a description of this classifier.
updateClassifier(Instance)
- Adds the supplied instance to the training set
LWL
public LWL()
listOptions
public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.
- Returns:
- an enumeration of all the available options.
setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
Parses a given list of options. Valid options are:
-D
Produce debugging output.
-K num
Set the number of neighbours used for setting kernel bandwidth.
(default all)
-W num
Set the weighting kernel shape to use. 1 = Inverse, 2 = Gaussian.
(default 0 = Linear)
-B classname
Specify the full class name of a base classifier (which needs
to be a WeightedInstancesHandler) (required).
- Parameters:
options - the list of options as an array of strings
- Throws:
- java.lang.Exception - if an option is not supported
getOptions
public java.lang.String[] getOptions()
Gets the current settings of the classifier.
- Returns:
- an array of strings suitable for passing to setOptions
setClassifier
public void setClassifier(Classifier newClassifier)
Set the classifier for locally weighted learning.
- Parameters:
newClassifier - the Classifier to use.
getClassifier
public Classifier getClassifier()
Get the classifier used as the classifier
- Returns:
- the classifier used as the classifier
setDebug
public void setDebug(boolean debug)
Sets whether debugging output should be produced
- Parameters:
debug - true if debugging output should be printed
getDebug
public boolean getDebug()
SGts whether debugging output should be produced
- Returns:
- true if debugging output should be printed
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
setWeightingKernel
public void setWeightingKernel(int kernel)
Sets the kernel weighting method to use. Must be one of LINEAR,
INVERSE, or GAUSS, other values are ignored.
- Parameters:
kernel - the new kernel method to use. Must be one of LINEAR,
INVERSE, or GAUSS
getWeightingKernel
public int getWeightingKernel()
Gets the kernel weighting method to use.
- Returns:
- the new kernel method to use. Will be one of LINEAR,
INVERSE, or GAUSS
buildClassifier
public void buildClassifier(Instances instances) throws java.lang.Exception
Generates the classifier.
- Parameters:
instances - set of instances serving as training data
- Throws:
- java.lang.Exception - if the classifier has not been generated successfully
- Overrides:
- buildClassifier in class Classifier
updateClassifier
public void updateClassifier(Instance instance) throws java.lang.Exception
Adds the supplied instance to the training set
- Parameters:
instance - the instance to add
- Throws:
- java.lang.Exception - if instance could not be incorporated
successfully
distributionForInstance
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
Calculates the class membership probabilities for the given test instance.
- Parameters:
instance - the instance to be classified
- Returns:
- preedicted class probability distribution
- Throws:
- java.lang.Exception - if distribution can't be computed successfully
- Overrides:
- distributionForInstance in class DistributionClassifier
toString
public java.lang.String toString()
Returns a description of this classifier.
- Returns:
- a description of this classifier as a string.
- Overrides:
- toString in class java.lang.Object
main
public static void main(java.lang.String argv[])
Main method for testing this class.
- Parameters:
argv - the options
All Packages Class Hierarchy This Package Previous Next Index WEKA's home