Overview | Package | Class | Tree | Deprecated | Index | Help | Weka's home
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weka.classifiers.lazy
Class LWL

    java.lang.Object
      weka.classifiers.AbstractClassifier
          weka.classifiers.SingleClassifierEnhancer
              weka.classifiers.lazy.LWL

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, Classifier, UpdateableClassifier, CapabilitiesHandler, 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:

     @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: 6055 $
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:
  Serialized Form

Field Summary
`static int` | `CONSTANT`
`static int` | `EPANECHNIKOV`
`static int` | `GAUSS`
`static int` | `INVERSE`
`static int` | `LINEAR` The available kernel weighting methods.
`static int` | `TRICUBE`

Constructor Summary
`LWL()` Constructor.

Method Summary
`void` | `buildClassifier(Instances instances)` Generates the classifier.
`double[]` | `distributionForInstance(Instance instance)` Calculates the class membership probabilities for the given test instance.
`java.util.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(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` | `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.

Methods inherited from class weka.classifiers.SingleClassifierEnhancer
`classifierTipText, getClassifier, setClassifier`

Methods inherited from class weka.classifiers.AbstractClassifier
`classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, setDebug`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### LINEAR

    public static final int LINEAR

  The available kernel weighting methods.

  See Also:
    Constant Field Values

### EPANECHNIKOV

    public static final int EPANECHNIKOV

See Also:
  Constant Field Values

### TRICUBE

    public static final int TRICUBE

See Also:
  Constant Field Values

### INVERSE

    public static final int INVERSE

See Also:
  Constant Field Values

### GAUSS

    public static final int GAUSS

See Also:
  Constant Field Values

### CONSTANT

    public static final int CONSTANT

See Also:
  Constant Field Values

Constructor Detail

### LWL

    public LWL()

  Constructor.

Method Detail

### globalInfo

    public java.lang.String globalInfo()

  Returns a string describing classifier.

  Returns:
    a description suitable for displaying in the explorer/experimenter gui

### getTechnicalInformation

    public 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.

  Specified by:
    `getTechnicalInformation` in interface `TechnicalInformationHandler`
  Returns:
    the technical information about this class

### enumerateMeasures

    public java.util.Enumeration enumerateMeasures()

  Returns an enumeration of the additional measure names produced by the neighbour search algorithm.

  Returns:
    an enumeration of the measure names

### getMeasure

    public double getMeasure(java.lang.String additionalMeasureName)

  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:
    `java.lang.IllegalArgumentException` - if the named measure is not supported

### listOptions

    public java.util.Enumeration listOptions()

  Returns an enumeration describing the available options.

  Specified by:
    `listOptions` in interface `OptionHandler`
  Overrides:
    `listOptions` in class `SingleClassifierEnhancer`
  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:

       -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 interface `OptionHandler`
  Overrides:
    `setOptions` in class `SingleClassifierEnhancer`
  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.

  Specified by:
    `getOptions` in interface `OptionHandler`
  Overrides:
    `getOptions` in class `SingleClassifierEnhancer`
  Returns:
    an array of strings suitable for passing to setOptions

### KNNTipText

    public java.lang.String 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

    public java.lang.String 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

    public java.lang.String nearestNeighbourSearchAlgorithmTipText()

  Returns the tip text for this property.

  Returns:
    tip text for this property suitable for displaying in the explorer/experimenter gui

### getNearestNeighbourSearchAlgorithm

    public NearestNeighbourSearch 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

    public Capabilities getCapabilities()

  Returns default capabilities of the classifier.

  Specified by:
    `getCapabilities` in interface `Classifier`
  Specified by:
    `getCapabilities` in interface `CapabilitiesHandler`
  Overrides:
    `getCapabilities` in class `SingleClassifierEnhancer`
  Returns:
    the capabilities of this classifier
  See Also:
    `Capabilities`

### buildClassifier

    public void buildClassifier(Instances instances)
                         throws java.lang.Exception

  Generates the classifier.

  Specified by:
    `buildClassifier` in interface `Classifier`
  Parameters:
    `instances` - set of instances serving as training data
  Throws:
    `java.lang.Exception` - if the classifier has not been generated successfully

### updateClassifier

    public void updateClassifier(Instance instance)
                          throws java.lang.Exception

  Adds the supplied instance to the training set.

  Specified by:
    `updateClassifier` in interface `UpdateableClassifier`
  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.

  Specified by:
    `distributionForInstance` in interface `Classifier`
  Overrides:
    `distributionForInstance` in class `AbstractClassifier`
  Parameters:
    `instance` - the instance to be classified
  Returns:
    preedicted class probability distribution
  Throws:
    `java.lang.Exception` - if distribution can't be computed successfully

### toString

    public java.lang.String toString()

  Returns a description of this classifier.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a description of this classifier as a string.

### getRevision

    public java.lang.String getRevision()

  Returns the revision string.

  Specified by:
    `getRevision` in interface `RevisionHandler`
  Overrides:
    `getRevision` in class `AbstractClassifier`
  Returns:
    the revision

### main

    public static void main(java.lang.String[] argv)

  Main method for testing this class.

  Parameters:
    `argv` - the options

Overview | Package | Class | Tree | Deprecated | Index | Help | Weka's home
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD