OneR

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.rules
Class OneR

    java.lang.Object
      weka.classifiers.Classifier
          weka.classifiers.rules.OneR

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, Sourcable, CapabilitiesHandler, OptionHandler, RevisionHandler, TechnicalInformationHandler

    public class OneR

extends Classifier
implements TechnicalInformationHandler, Sourcable

Class for building and using a 1R classifier; in other words, uses the minimum-error attribute for prediction, discretizing numeric attributes. For more information, see:
R.C. Holte (1993). Very simple classification rules perform well on most commonly used datasets. Machine Learning. 11:63-91.

BibTeX:

     @article{Holte1993,
        author = {R.C. Holte},
        journal = {Machine Learning},
        pages = {63-91},
        title = {Very simple classification rules perform well on most commonly used datasets},
        volume = {11},
        year = {1993}
     }

Valid options are:

     -B <minimum bucket size>
      The minimum number of objects in a bucket (default: 6).

Version:
  $Revision: 1.26 $
Author:
  Ian H. Witten (ihw@cs.waikato.ac.nz)
See Also:
  Serialized Form

Constructor Summary
`OneR()`

Method Summary
`void` | `buildClassifier(Instances instances)` Generates the classifier.
`double` | `classifyInstance(Instance inst)` Classifies a given instance.
`Capabilities` | `getCapabilities()` Returns default capabilities of the classifier.
`int` | `getMinBucketSize()` Get the value of minBucketSize.
`java.lang.String[]` | `getOptions()` Gets the current settings of the OneR 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.
`java.lang.String` | `globalInfo()` Returns a string describing classifier
`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` | `minBucketSizeTipText()` Returns the tip text for this property
`weka.classifiers.rules.OneR.OneRRule` | `newNominalRule(Attribute attr, Instances data, int[] missingValueCounts)` Create a rule branching on this nominal attribute.
`weka.classifiers.rules.OneR.OneRRule` | `newNumericRule(Attribute attr, Instances data, int[] missingValueCounts)` Create a rule branching on this numeric attribute
`weka.classifiers.rules.OneR.OneRRule` | `newRule(Attribute attr, Instances data)` Create a rule branching on this attribute.
`void` | `setMinBucketSize(int v)` Set the value of minBucketSize.
`void` | `setOptions(java.lang.String[] options)` Parses a given list of options.
`java.lang.String` | `toSource(java.lang.String className)` Returns a string that describes the classifier as source.
`java.lang.String` | `toString()` Returns a description of the classifier

Methods inherited from class weka.classifiers.Classifier
`debugTipText, distributionForInstance, forName, getDebug, makeCopies, makeCopy, setDebug`

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

Constructor Detail

### OneR

    public OneR()

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

### classifyInstance

    public double classifyInstance(Instance inst)
                            throws java.lang.Exception

  Classifies a given instance.

  Overrides:
    `classifyInstance` in class `Classifier`
  Parameters:
    `inst` - the instance to be classified
  Returns:
    the classification of the instance
  Throws:
    `java.lang.Exception` - if an error occurred during the prediction

### getCapabilities

    public Capabilities getCapabilities()

  Returns default capabilities of the classifier.

  Specified by:
    `getCapabilities` in interface `CapabilitiesHandler`
  Overrides:
    `getCapabilities` in class `Classifier`
  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 class `Classifier`
  Parameters:
    `instances` - the instances to be used for building the classifier
  Throws:
    `java.lang.Exception` - if the classifier can't be built successfully

### newRule

    public weka.classifiers.rules.OneR.OneRRule newRule(Attribute attr,
                                                        Instances data)
                                                 throws java.lang.Exception

  Create a rule branching on this attribute.

  Parameters:
    `attr` - the attribute to branch on
    `data` - the data to be used for creating the rule
  Returns:
    the generated rule
  Throws:
    `java.lang.Exception` - if the rule can't be built successfully

### newNominalRule

    public weka.classifiers.rules.OneR.OneRRule newNominalRule(Attribute attr,
                                                               Instances data,
                                                               int[] missingValueCounts)
                                                        throws java.lang.Exception

  Create a rule branching on this nominal attribute.

  Parameters:
    `attr` - the attribute to branch on
    `data` - the data to be used for creating the rule
    `missingValueCounts` - to be filled in
  Returns:
    the generated rule
  Throws:
    `java.lang.Exception` - if the rule can't be built successfully

### newNumericRule

    public weka.classifiers.rules.OneR.OneRRule newNumericRule(Attribute attr,
                                                               Instances data,
                                                               int[] missingValueCounts)
                                                        throws java.lang.Exception

  Create a rule branching on this numeric attribute

  Parameters:
    `attr` - the attribute to branch on
    `data` - the data to be used for creating the rule
    `missingValueCounts` - to be filled in
  Returns:
    the generated rule
  Throws:
    `java.lang.Exception` - if the rule can't be built successfully

### listOptions

    public java.util.Enumeration listOptions()

  Returns an enumeration describing the available options..

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

       -B <minimum bucket size>
        The minimum number of objects in a bucket (default: 6).

  Specified by:
    `setOptions` in interface `OptionHandler`
  Overrides:
    `setOptions` in class `Classifier`
  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 OneR classifier.

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

### toSource

    public java.lang.String toSource(java.lang.String className)
                              throws java.lang.Exception

  Returns a string that describes the classifier as source. The classifier will be contained in a class with the given name (there may be auxiliary classes), and will contain a method with the signature:

       public static double classify(Object[] i);

  where the array `i` contains elements that are either Double, String, with missing values represented as null. The generated code is public domain and comes with no warranty.

  Specified by:
    `toSource` in interface `Sourcable`
  Parameters:
    `className` - the name that should be given to the source class.
  Returns:
    the object source described by a string
  Throws:
    `java.lang.Exception` - if the souce can't be computed

### toString

    public java.lang.String toString()

  Returns a description of the classifier

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string representation of the classifier

### minBucketSizeTipText

    public java.lang.String minBucketSizeTipText()

  Returns the tip text for this property

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

### getMinBucketSize

    public int getMinBucketSize()

  Get the value of minBucketSize.

  Returns:
    Value of minBucketSize.

### setMinBucketSize

    public void setMinBucketSize(int v)

  Set the value of minBucketSize.

  Parameters:
    `v` - Value to assign to minBucketSize.

### getRevision

    public java.lang.String getRevision()

  Returns the revision string.

  Specified by:
    `getRevision` in interface `RevisionHandler`
  Returns:
    the revision

### main

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

  Main method for testing this class

  Parameters:
    `argv` - the commandline 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