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)

Constructor Index

 o LWL()
 

Method Index

 o buildClassifier(Instances)
Generates the classifier.
 o distributionForInstance(Instance)
Calculates the class membership probabilities for the given test instance.
 o getClassifier()
Get the classifier used as the classifier
 o getDebug()
SGts whether debugging output should be produced
 o getKNN()
Gets the number of neighbours used for kernel bandwidth setting.
 o getOptions()
Gets the current settings of the classifier.
 o getWeightingKernel()
Gets the kernel weighting method to use.
 o listOptions()
Returns an enumeration describing the available options.
 o main(String[])
Main method for testing this class.
 o setClassifier(Classifier)
Set the classifier for locally weighted learning.
 o setDebug(boolean)
Sets whether debugging output should be produced
 o setKNN(int)
Sets the number of neighbours used for kernel bandwidth setting.
 o setOptions(String[])
Parses a given list of options.
 o setWeightingKernel(int)
Sets the kernel weighting method to use.
 o toString()
Returns a description of this classifier.
 o updateClassifier(Instance)
Adds the supplied instance to the training set

Constructor Detail

 o LWL
public LWL()

Method Detail

 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
Returns:
an enumeration of all the available options.
 o 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
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of the classifier.
Returns:
an array of strings suitable for passing to setOptions
 o setClassifier
public void setClassifier(Classifier newClassifier)
          Set the classifier for locally weighted learning.
Parameters:
newClassifier - the Classifier to use.
 o getClassifier
public Classifier getClassifier()
          Get the classifier used as the classifier
Returns:
the classifier used as the classifier
 o setDebug
public void setDebug(boolean debug)
          Sets whether debugging output should be produced
Parameters:
debug - true if debugging output should be printed
 o getDebug
public boolean getDebug()
          SGts whether debugging output should be produced
Returns:
true if debugging output should be printed
 o 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.
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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