weka.classifiers.rules
Class Ridor

java.lang.Object
  extended byweka.classifiers.Classifier
      extended byweka.classifiers.rules.Ridor
All Implemented Interfaces:
AdditionalMeasureProducer, java.lang.Cloneable, OptionHandler, java.io.Serializable, WeightedInstancesHandler

public class Ridor
extends Classifier
implements OptionHandler, AdditionalMeasureProducer, WeightedInstancesHandler

The implementation of a RIpple-DOwn Rule learner. It generates the default rule first and then the exceptions for the default rule with the least (weighted) error rate. Then it generates the "best" exceptions for each exception and iterates until pure. Thus it performs a tree-like expansion of exceptions and the leaf has only default rule but no exceptions.
The exceptions are a set of rules that predict the class other than class in default rule. IREP is used to find out the exceptions.

There are five inner classes defined in this class.
The first is Ridor_node, which implements one node in the Ridor tree. It's basically composed of a default class and a set of exception rules to the default class.
The second inner class is RidorRule, which implements a single exception rule using REP.
The last three inner classes are only used in RidorRule. They are Antd, NumericAntd and NominalAntd, which all implement a single antecedent in the RidorRule.
The Antd class is an abstract class, which has two subclasses, NumericAntd and NominalAntd, to implement the corresponding abstract functions. These two subclasses implement the functions related to a antecedent with a nominal attribute and a numeric attribute respectively.

Version:
$Revision: 1.10 $
See Also:
Serialized Form

Nested Class Summary
private  class Ridor.Antd
          The single antecedent in the rule, which is composed of an attribute and the corresponding value.
private  class Ridor.NominalAntd
          The antecedent with nominal attribute
private  class Ridor.NumericAntd
          The antecedent with numeric attribute
private  class Ridor.Ridor_node
          Private class implementing the single node of Ridor.
private  class Ridor.RidorRule
          This class implements a single rule that predicts the 2-class distribution.
 
Field Summary
private  Attribute m_Class
          The class attribute of the data
private  double m_Cover
          Statistics of the data
private  double m_Err
          Statistics of the data
private  int m_Folds
          The number of folds to split data into Grow and Prune for IREP
private  boolean m_IsAllErr
          Whether use error rate on all the data
private  boolean m_IsMajority
          Whether use majority class as default class
private  double m_MinNo
          The minimal number of instance weights within a split
private  java.util.Random m_Random
          Random object for randomization
private  Ridor.Ridor_node m_Root
          The root of Ridor
private  int m_Seed
          The seed to perform randomization
private  int m_Shuffle
          The number of shuffles performed on the data for randomization
 
Fields inherited from class weka.classifiers.Classifier
m_Debug
 
Constructor Summary
Ridor()
           
 
Method Summary
 void buildClassifier(Instances instances)
          Builds a ripple-down manner rule learner.
private  double classify(Ridor.Ridor_node node, Instance datum)
          Classify the test instance with one node of Ridor
 double classifyInstance(Instance datum)
          Classify the test instance with the rule learner
 java.util.Enumeration enumerateMeasures()
          Returns an enumeration of the additional measure names
 java.lang.String foldsTipText()
          Returns the tip text for this property
 int getFolds()
           
 boolean getMajorityClass()
           
 double getMeasure(java.lang.String additionalMeasureName)
          Returns the value of the named measure
 double getMinNo()
           
 java.lang.String[] getOptions()
          Gets the current settings of the Classifier.
 int getSeed()
           
 int getShuffle()
           
 boolean getWholeDataErr()
           
 java.lang.String globalInfo()
          Returns a string describing classifier
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options Valid options are: -F number
Set number of folds for reduced error pruning.
static void main(java.lang.String[] args)
          Main method.
 java.lang.String majorityClassTipText()
          Returns the tip text for this property
 java.lang.String minNoTipText()
          Returns the tip text for this property
private  double numRules()
          Measure the number of rules in total in the model
 java.lang.String seedTipText()
          Returns the tip text for this property
 void setFolds(int fold)
           
 void setMajorityClass(boolean m)
           
 void setMinNo(double m)
           
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setSeed(int s)
           
 void setShuffle(int sh)
           
 void setWholeDataErr(boolean a)
           
 java.lang.String shuffleTipText()
          Returns the tip text for this property
 java.lang.String toString()
          Prints the all the rules of the rule learner.
 java.lang.String wholeDataErrTipText()
          Returns the tip text for this property
 
Methods inherited from class weka.classifiers.Classifier
debugTipText, distributionForInstance, forName, getDebug, makeCopies, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Folds

private int m_Folds
The number of folds to split data into Grow and Prune for IREP


m_Shuffle

private int m_Shuffle
The number of shuffles performed on the data for randomization


m_Random

private java.util.Random m_Random
Random object for randomization


m_Seed

private int m_Seed
The seed to perform randomization


m_IsAllErr

private boolean m_IsAllErr
Whether use error rate on all the data


m_IsMajority

private boolean m_IsMajority
Whether use majority class as default class


m_Root

private Ridor.Ridor_node m_Root
The root of Ridor


m_Class

private Attribute m_Class
The class attribute of the data


m_Cover

private double m_Cover
Statistics of the data


m_Err

private double m_Err
Statistics of the data


m_MinNo

private double m_MinNo
The minimal number of instance weights within a split

Constructor Detail

Ridor

public Ridor()
Method Detail

globalInfo

public java.lang.String globalInfo()
Returns a string describing classifier

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

buildClassifier

public void buildClassifier(Instances instances)
                     throws java.lang.Exception
Builds a ripple-down manner rule learner.

Specified by:
buildClassifier in class Classifier
Parameters:
instances - set of instances serving as training data
Throws:
java.lang.Exception - if classifier can't be built successfully

classifyInstance

public double classifyInstance(Instance datum)
Classify the test instance with the rule learner

Overrides:
classifyInstance in class Classifier
Parameters:
datum - the instance to be classified
Returns:
the classification

classify

private double classify(Ridor.Ridor_node node,
                        Instance datum)
Classify the test instance with one node of Ridor

Parameters:
node - the node of Ridor to classify the test instance
Returns:
the classification

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration describing the available options Valid options are:

-F number
Set number of folds for reduced error pruning. One fold is used as the pruning set. (Default: 3)

-S number
Set number of shuffles for randomization. (Default: 10)

-A
Set flag of whether use the error rate of all the data to select the default class in each step. If not set, the learner will only use the error rate in the pruning data

-M
Set flag of whether use the majority class as the default class in each step instead of choosing default class based on the error rate (if the flag is not set)

-N number
Set the minimal weights of instances within a split. (Default: 2)

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.

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

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

foldsTipText

public java.lang.String foldsTipText()
Returns the tip text for this property

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

setFolds

public void setFolds(int fold)

getFolds

public int getFolds()

shuffleTipText

public java.lang.String shuffleTipText()
Returns the tip text for this property

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

setShuffle

public void setShuffle(int sh)

getShuffle

public int getShuffle()

seedTipText

public java.lang.String seedTipText()
Returns the tip text for this property

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

setSeed

public void setSeed(int s)

getSeed

public int getSeed()

wholeDataErrTipText

public java.lang.String wholeDataErrTipText()
Returns the tip text for this property

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

setWholeDataErr

public void setWholeDataErr(boolean a)

getWholeDataErr

public boolean getWholeDataErr()

majorityClassTipText

public java.lang.String majorityClassTipText()
Returns the tip text for this property

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

setMajorityClass

public void setMajorityClass(boolean m)

getMajorityClass

public boolean getMajorityClass()

minNoTipText

public java.lang.String minNoTipText()
Returns the tip text for this property

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

setMinNo

public void setMinNo(double m)

getMinNo

public double getMinNo()

enumerateMeasures

public java.util.Enumeration enumerateMeasures()
Returns an enumeration of the additional measure names

Specified by:
enumerateMeasures in interface AdditionalMeasureProducer
Returns:
an enumeration of the measure names

getMeasure

public double getMeasure(java.lang.String additionalMeasureName)
Returns the value of the named measure

Specified by:
getMeasure in interface AdditionalMeasureProducer
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

numRules

private double numRules()
Measure the number of rules in total in the model

Returns:
the number of rules

toString

public java.lang.String toString()
Prints the all the rules of the rule learner.

Returns:
a textual description of the classifier

main

public static void main(java.lang.String[] args)
Main method.

Parameters:
args - the options for the classifier