weka.classifiers.rules
Class JRip.RipperRule

java.lang.Object
  extended byweka.classifiers.rules.Rule
      extended byweka.classifiers.rules.JRip.RipperRule
All Implemented Interfaces:
Copyable, java.io.Serializable, WeightedInstancesHandler
Enclosing class:
JRip

protected class JRip.RipperRule
extends Rule

This class implements a single rule that predicts specified class. A rule consists of antecedents "AND"ed together and the consequent (class value) for the classification. In this class, the Information Gain (p*[log(p/t) - log(P/T)]) is used to select an antecedent and Reduced Error Prunning (REP) with the metric of accuracy rate p/(p+n) or (TP+TN)/(P+N) is used to prune the rule.

See Also:
Serialized Form

Field Summary
protected  FastVector m_Antds
          The vector of antecedents of this rule
private  double m_Consequent
          The internal representation of the class label to be predicted
 
Constructor Summary
JRip.RipperRule()
          Constructor
 
Method Summary
private  double computeDefAccu(Instances data)
          Private function to compute default number of accurate instances in the specified data for the consequent of the rule
private  Instances computeInfoGain(Instances instances, double defAcRt, JRip.Antd antd)
          Compute the best information gain for the specified antecedent
 java.lang.Object copy()
          Get a shallow copy of this rule
 boolean covers(Instance datum)
          Whether the instance covered by this rule
 double getConsequent()
          Get the consequent of this rule, i.e. the predicted class
 void grow(Instances data)
          Build one rule using the growing data
 boolean hasAntds()
          Whether this rule has antecedents, i.e. whether it is a default rule
 void prune(Instances pruneData, boolean useWhole)
          Prune all the possible final sequences of the rule using the pruning data.
 void setConsequent(double cl)
           
 double size()
          the number of antecedents of the rule
 java.lang.String toString(Attribute classAttr)
          Prints this rule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Consequent

private double m_Consequent
The internal representation of the class label to be predicted


m_Antds

protected FastVector m_Antds
The vector of antecedents of this rule

Constructor Detail

JRip.RipperRule

public JRip.RipperRule()
Constructor

Method Detail

setConsequent

public void setConsequent(double cl)

getConsequent

public double getConsequent()
Description copied from class: Rule
Get the consequent of this rule, i.e. the predicted class

Specified by:
getConsequent in class Rule
Returns:
the consequent

copy

public java.lang.Object copy()
Get a shallow copy of this rule

Specified by:
copy in interface Copyable
Overrides:
copy in class Rule
Returns:
the copy

covers

public boolean covers(Instance datum)
Whether the instance covered by this rule

Specified by:
covers in class Rule
Returns:
the boolean value indicating whether the instance is covered by this rule

hasAntds

public boolean hasAntds()
Whether this rule has antecedents, i.e. whether it is a default rule

Specified by:
hasAntds in class Rule
Returns:
the boolean value indicating whether the rule has antecedents

size

public double size()
the number of antecedents of the rule

Specified by:
size in class Rule
Returns:
the size of this rule

computeDefAccu

private double computeDefAccu(Instances data)
Private function to compute default number of accurate instances in the specified data for the consequent of the rule

Parameters:
data - the data in question
Returns:
the default accuracy number

grow

public void grow(Instances data)
          throws java.lang.Exception
Build one rule using the growing data

Specified by:
grow in class Rule
Parameters:
data - the growing data used to build the rule
Throws:
if - the consequent is not set yet
java.lang.Exception

computeInfoGain

private Instances computeInfoGain(Instances instances,
                                  double defAcRt,
                                  JRip.Antd antd)
Compute the best information gain for the specified antecedent

Parameters:
instances - the data based on which the infoGain is computed
defAcRt - the default accuracy rate of data
antd - the specific antecedent
Returns:
the data covered by the antecedent

prune

public void prune(Instances pruneData,
                  boolean useWhole)
Prune all the possible final sequences of the rule using the pruning data. The measure used to prune the rule is based on flag given.

Parameters:
pruneData - the pruning data used to prune the rule
useWhole - flag to indicate whether use the error rate of the whole pruning data instead of the data covered

toString

public java.lang.String toString(Attribute classAttr)
Prints this rule

Parameters:
classAttr - the class attribute in the data
Returns:
a textual description of this rule