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.Classifier
          weka.classifiers.SingleClassifierEnhancer
              weka.classifiers.lazy.LWL

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, UpdateableClassifier, OptionHandler, WeightedInstancesHandler

    public class LWL

extends SingleClassifierEnhancer
implements 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.

-N
Do not normalize numeric attributes' values in distance calculation.

-K num
Set the number of neighbours used for setting kernel bandwidth. (default all)

-U num
Set the weighting kernel shape to use. 0 = Linear, 1 = Epnechnikov, 2 = Tricube, 3 = Inverse, 4 = Gaussian and 5 = Constant. (default 0 = Linear)

-W classname
Specify the full class name of a base classifier (which needs to be a WeightedInstancesHandler).

Version:
  $Revision: 1.12.2.1 $
Author:
  Len Trigg (trigg@cs.waikato.ac.nz), Eibe Frank (eibe@cs.waikato.ac.nz), Ashraf M. Kibriya (amk14@waikato.ac.nz)
See Also:
  Serialized Form

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.lang.String` | `dontNormalizeTipText()` Returns the tip text for this property
`boolean` | `getDontNormalize()` Gets whether if the numeric attribute values are not to be normalized for calculating the distances.
`int` | `getKNN()` Gets the number of neighbours used for kernel bandwidth setting.
`java.lang.String[]` | `getOptions()` Gets the current settings of the classifier.
`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.
`void` | `setDontNormalize(boolean normalize)` Sets whether if the numeric attribute values are not to be normalized for calculating the distances between them.
`void` | `setKNN(int knn)` Sets the number of neighbours used for kernel bandwidth setting.
`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.Classifier
`classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, setDebug`

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

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

### 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:

  -D
  Produce debugging output.

  -N
  Do not normalize numeric attributes' values in distance calculation. (default DO normalization)

  -K num
  Set the number of neighbours used for setting kernel bandwidth. (default all)

  -U num
  Set the weighting kernel shape to use. 0 = Linear, 1 = Epnechnikov, 2 = Tricube, 3 = Inverse, 4 = Gaussian and 5 = Constant. (default 0 = Linear)

  -W classname
  Specify the full class name of a base classifier (which needs to be a WeightedInstancesHandler).

  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.

### dontNormalizeTipText

    public java.lang.String dontNormalizeTipText()

  Returns the tip text for this property

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

### getDontNormalize

    public boolean getDontNormalize()

  Gets whether if the numeric attribute values are not to be normalized for calculating the distances.

  Returns:
    true if normalization is not to be performed

### setDontNormalize

    public void setDontNormalize(boolean normalize)

  Sets whether if the numeric attribute values are not to be normalized for calculating the distances between them.

  Parameters:
    `dontNormalize` - true if normalization is not to be performed

### buildClassifier

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

  Generates the classifier.

  Specified by:
    `buildClassifier` in class `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.

  Overrides:
    `distributionForInstance` in class `Classifier`
  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.

### 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