Class JRip.RipperRule

java.lang.Object
weka.classifiers.rules.Rule
weka.classifiers.rules.JRip.RipperRule
All Implemented Interfaces:
Serializable, Copyable, RevisionHandler, WeightedInstancesHandler
Enclosing class:
JRip

public 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:
  • Constructor Details

    • RipperRule

      public RipperRule()
      Constructor
  • Method Details

    • cleanUp

      public void cleanUp(Instances data)
      Removes redundant tests in the rule.
      Parameters:
      data - an instance object that contains the appropriate header information for the attributes.
    • setConsequent

      public void setConsequent(double cl)
      Sets the internal representation of the class label to be predicted
      Parameters:
      cl - the internal representation of the class label to be predicted
    • getConsequent

      public double getConsequent()
      Gets the internal representation of the class label to be predicted
      Specified by:
      getConsequent in class Rule
      Returns:
      the internal representation of the class label to be predicted
    • copy

      public 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
      Parameters:
      datum - the instance in question
      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
    • getAntds

      public ArrayList<JRip.Antd> getAntds()
      Return the antecedents
      Returns:
      the vector of antecedents
    • size

      public double size()
      the number of antecedents of the rule
      Specified by:
      size in class Rule
      Returns:
      the size of this rule
    • grow

      public void grow(Instances data) throws 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:
      Exception - if the consequent is not set yet
    • 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 String toString(Attribute classAttr)
      Prints this rule
      Parameters:
      classAttr - the class attribute in the data
      Returns:
      a textual description of this rule
    • getRevision

      public String getRevision()
      Returns the revision string.
      Returns:
      the revision