Package weka.classifiers.lazy

# Class KStar

java.lang.Object
weka.classifiers.AbstractClassifier
weka.classifiers.lazy.KStar

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `Classifier`, `KStarConstants`, `UpdateableClassifier`, `BatchPredictor`, `CapabilitiesHandler`, `CapabilitiesIgnorer`, `CommandlineRunnable`, `OptionHandler`, `RevisionHandler`, `TechnicalInformationHandler`

public class KStar extends AbstractClassifier implements KStarConstants, UpdateableClassifier, TechnicalInformationHandler
K* is an instance-based classifier, that is the class of a test instance is based upon the class of those training instances similar to it, as determined by some similarity function. It differs from other instance-based learners in that it uses an entropy-based distance function.
For more information on K*, see
John G. Cleary, Leonard E. Trigg: K*: An Instance-based Learner Using an Entropic Distance Measure. In: 12th International Conference on Machine Learning, 108-114, 1995.

BibTeX:

     @inproceedings{Cleary1995,
        author = {John G. Cleary and Leonard E. Trigg},
        booktitle = {12th International Conference on Machine Learning},
        pages = {108-114},
        title = {K*: An Instance-based Learner Using an Entropic Distance Measure},
        year = {1995}
     }

Valid options are:

     -B <num>
      Manual blend setting (default 20%)

     -E
      Enable entropic auto-blend setting (symbolic class only)

     -M <char>
      Specify the missing value treatment mode (default a)
      Valid options are: a(verage), d(elete), m(axdiff), n(ormal)

Version:
  $Revision: 15520 $
Author:
  Len Trigg (len@reeltwo.com), Abdelaziz Mahoui (am14@cs.waikato.ac.nz) - Java port
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Tag[]`
  `TAGS_MISSING`
  Define possible missing value handling methods

  ### Fields inherited from class weka.classifiers.AbstractClassifier

  `BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT`

  ### Fields inherited from interface weka.classifiers.lazy.kstar.KStarConstants

  `B_ENTROPY, B_SPHERE, EPSILON, FLOOR, FLOOR1, INITIAL_STEP, LOG2, M_AVERAGE, M_DELETE, M_MAXDIFF, M_NORMAL, NUM_RAND_COLS, OFF, ON, ROOT_FINDER_ACCURACY, ROOT_FINDER_MAX_ITER`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `KStar()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `buildClassifier(Instances instances)`
  Generates the classifier.
  `double[]`
  `distributionForInstance(Instance instance)`
  Calculates the class membership probabilities for the given test instance.
  `String`
  `entropicAutoBlendTipText()`
  Returns the tip text for this property
  `Capabilities`
  `getCapabilities()`
  Returns default capabilities of the classifier.
  `boolean`
  `getEntropicAutoBlend()`
  Get whether entropic blending being used
  `int`
  `getGlobalBlend()`
  Get the value of the global blend parameter
  `SelectedTag`
  `getMissingMode()`
  Gets the method to use for handling missing values.
  `String[]`
  `getOptions()`
  Gets the current settings of K*.
  `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.
  `String`
  `globalBlendTipText()`
  Returns the tip text for this property
  `String`
  `globalInfo()`
  Returns a string describing classifier
  `Enumeration<Option>`
  `listOptions()`
  Returns an enumeration describing the available options.
  `static void`
  `main(String[] argv)`
  Main method for testing this class.
  `String`
  `missingModeTipText()`
  Returns the tip text for this property
  `void`
  `setEntropicAutoBlend(boolean e)`
  Set whether entropic blending is to be used.
  `void`
  `setGlobalBlend(int b)`
  Set the global blend parameter
  `void`
  `setMissingMode(SelectedTag newMode)`
  Sets the method to use for handling missing values.
  `void`
  `setOptions(String[] options)`
  Parses a given list of options.
  `String`
  `toString()`
  Returns a description of this classifier.
  `void`
  `updateClassifier(Instance instance)`
  Adds the supplied instance to the training set

  ### Methods inherited from class weka.classifiers.AbstractClassifier

  `batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### TAGS_MISSING

    public static final Tag[] TAGS_MISSING
    Define possible missing value handling methods

- ## Constructor Details

  - ### KStar

    public KStar()

- ## Method Details

  - ### globalInfo

    public 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

  - ### getCapabilities

    public Capabilities getCapabilities()
    Returns default capabilities of the classifier.
    Specified by:
      `getCapabilities` in interface `CapabilitiesHandler`
    Specified by:
      `getCapabilities` in interface `Classifier`
    Overrides:
      `getCapabilities` in class `AbstractClassifier`
    Returns:
      the capabilities of this classifier
    See Also:
      - `Capabilities`

  - ### buildClassifier

    public void buildClassifier(Instances instances) throws Exception
    Generates the classifier.
    Specified by:
      `buildClassifier` in interface `Classifier`
    Parameters:
      `instances` - set of instances serving as training data
    Throws:
      `Exception` - if the classifier has not been generated successfully

  - ### updateClassifier

    public void updateClassifier(Instance instance) throws Exception
    Adds the supplied instance to the training set
    Specified by:
      `updateClassifier` in interface `UpdateableClassifier`
    Parameters:
      `instance` - the instance to add
    Throws:
      `Exception` - if instance could not be incorporated successfully

  - ### distributionForInstance

    public double[] distributionForInstance(Instance instance) throws 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:
      predicted class probability distribution
    Throws:
      `Exception` - if an error occurred during the prediction

  - ### missingModeTipText

    public String missingModeTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### getMissingMode

    public SelectedTag getMissingMode()
    Gets the method to use for handling missing values. Will be one of M_NORMAL, M_AVERAGE, M_MAXDIFF or M_DELETE.
    Returns:
      the method used for handling missing values.

  - ### setMissingMode

    public void setMissingMode(SelectedTag newMode)
    Sets the method to use for handling missing values. Values other than M_NORMAL, M_AVERAGE, M_MAXDIFF and M_DELETE will be ignored.
    Parameters:
      `newMode` - the method to use for handling missing values.

  - ### listOptions

    public Enumeration<Option> listOptions()
    Returns an enumeration describing the available options.
    Specified by:
      `listOptions` in interface `OptionHandler`
    Overrides:
      `listOptions` in class `AbstractClassifier`
    Returns:
      an enumeration of all the available options.

  - ### globalBlendTipText

    public String globalBlendTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### setGlobalBlend

    public void setGlobalBlend(int b)
    Set the global blend parameter
    Parameters:
      `b` - the value for global blending

  - ### getGlobalBlend

    public int getGlobalBlend()
    Get the value of the global blend parameter
    Returns:
      the value of the global blend parameter

  - ### entropicAutoBlendTipText

    public String entropicAutoBlendTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### setEntropicAutoBlend

    public void setEntropicAutoBlend(boolean e)
    Set whether entropic blending is to be used.
    Parameters:
      `e` - true if entropic blending is to be used

  - ### getEntropicAutoBlend

    public boolean getEntropicAutoBlend()
    Get whether entropic blending being used
    Returns:
      true if entropic blending is used

  - ### setOptions

    public void setOptions(String[] options) throws Exception
    Parses a given list of options.

    Valid options are:

         -B <num>
          Manual blend setting (default 20%)

         -E
          Enable entropic auto-blend setting (symbolic class only)

         -M <char>
          Specify the missing value treatment mode (default a)
          Valid options are: a(verage), d(elete), m(axdiff), n(ormal)

    Specified by:
      `setOptions` in interface `OptionHandler`
    Overrides:
      `setOptions` in class `AbstractClassifier`
    Parameters:
      `options` - the list of options as an array of strings
    Throws:
      `Exception` - if an option is not supported

  - ### getOptions

    public String[] getOptions()
    Gets the current settings of K*.
    Specified by:
      `getOptions` in interface `OptionHandler`
    Overrides:
      `getOptions` in class `AbstractClassifier`
    Returns:
      an array of strings suitable for passing to setOptions()

  - ### toString

    public String toString()
    Returns a description of this classifier.
    Overrides:
      `toString` in class `Object`
    Returns:
      a description of this classifier as a string.

  - ### main

    public static void main(String[] argv)
    Main method for testing this class.
    Parameters:
      `argv` - should contain command line options (see setOptions)

  - ### getRevision

    public String getRevision()
    Returns the revision string.
    Specified by:
      `getRevision` in interface `RevisionHandler`
    Overrides:
      `getRevision` in class `AbstractClassifier`
    Returns:
      the revision