weka.classifiers
Class OneR

java.lang.Object
  |
  +--weka.classifiers.Classifier
        |
        +--weka.classifiers.OneR
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable

public class OneR
extends Classifier
implements OptionHandler

Class for building and using a 1R classifier. For more information, see

R.C. Holte (1993). Very simple classification rules perform well on most commonly used datasets. Machine Learning, Vol. 11, pp. 63-91.

Valid options are:

-B num
Specify the minimum number of objects in a bucket (default: 6).

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.
 int getMinBucketSize()
          Get the value of minBucketSize.
 java.lang.String[] getOptions()
          Gets the current settings of the OneR 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
 weka.classifiers.OneR.OneRRule newNominalRule(Attribute attr, Instances data, int[] missingValueCounts)
          Create a rule branching on this nominal attribute.
 weka.classifiers.OneR.OneRRule newNumericRule(Attribute attr, Instances data, int[] missingValueCounts)
          Create a rule branching on this numeric attribute
 weka.classifiers.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 toString()
          Returns a description of the classifier
 
Methods inherited from class weka.classifiers.Classifier
forName, makeCopies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OneR

public OneR()
Method Detail

classifyInstance

public double classifyInstance(Instance inst)
Classifies a given instance.
Overrides:
classifyInstance in class Classifier
Parameters:
inst - the instance to be classified

buildClassifier

public void buildClassifier(Instances instances)
                     throws java.lang.Exception
Generates the classifier.
Overrides:
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.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
Throws:
java.lang.Exception - if the rule can't be built successfully

newNominalRule

public weka.classifiers.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
Throws:
java.lang.Exception - if the rule can't be built successfully

newNumericRule

public weka.classifiers.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
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
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 num
Specify the minimum number of objects in a bucket (default: 6).

Specified by:
setOptions in interface OptionHandler
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
Returns:
an array of strings suitable for passing to setOptions

toString

public java.lang.String toString()
Returns a description of the classifier
Overrides:
toString in class java.lang.Object

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.

main

public static void main(java.lang.String[] argv)
Main method for testing this class