weka.classifiers.rules
Class Ridor.RidorRule

java.lang.Object
  extended byweka.classifiers.rules.Ridor.RidorRule
All Implemented Interfaces:
WeightedInstancesHandler
Enclosing class:
Ridor

private class Ridor.RidorRule
extends java.lang.Object
implements WeightedInstancesHandler

This class implements a single rule that predicts the 2-class distribution. A rule consists of antecedents "AND"ed together and the consequent (class value) for the classification. In this case, the consequent is the distribution of the available classes (always 2 classes) in the dataset. In this class, the Information Gain (p*[log(p/t) - log(P/T)]) is used to select an antecedent and Reduced Error Prunning (REP) is used to prune the rule.


Field Summary
private  double m_AccuG
          The accurate and covered data of this rule in the growing data
protected  FastVector m_Antds
          The vector of antecedents of this rule
private  double m_Class
          The internal representation of the class label to be predicted
private  Attribute m_ClassAttribute
          The class attribute of the data
private  double m_CoverG
          The accurate and covered data of this rule in the growing data
private  double m_CoverP
          The sum of weights of the data covered by this rule in the pruning data
private  double m_Worth
          The worth value of this rule, in this case, accurate # in pruning data
private  double m_WorthRate
          The worth rate of this rule, in this case, accuracy rate in the pruning data
 
Constructor Summary
private Ridor.RidorRule()
           
 
Method Summary
 void buildClassifier(Instances instances)
          Builds a single rule learner with REP dealing with 2 classes.
private  double computeDefAccu(Instances data)
          Private function to compute default number of accurate instances in the specified data for m_Class
private  Instances computeInfoGain(Instances instances, double defAcRt, Ridor.Antd antd)
          Compute the best information gain for the specified antecedent
 Instances[] coveredByRule(Instances insts)
          Find all the instances in the dataset covered by this rule.
 double getAccuG()
           
 double getCoverG()
           
 double getCoverP()
           
 double getPredictedClass()
           
 double getWorth()
           
 double getWorthRate()
          The following are get functions after prune() has set the value of worthRate and worth
private  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
 boolean isCover(Instance datum)
          Whether the instance covered by this rule
private  void prune(Instances pruneData)
          Prune the rule using the pruning data and update the worth parameters for this rule The accuracy rate is used to prune the rule.
 void setPredictedClass(double cl)
          The access functions for parameters
 java.lang.String toString()
          Prints this rule
 java.lang.String toString(java.lang.String att, java.lang.String cl)
          Prints this rule with the specified class label
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Class

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


m_ClassAttribute

private Attribute m_ClassAttribute
The class attribute of the data


m_Antds

protected FastVector m_Antds
The vector of antecedents of this rule


m_WorthRate

private double m_WorthRate
The worth rate of this rule, in this case, accuracy rate in the pruning data


m_Worth

private double m_Worth
The worth value of this rule, in this case, accurate # in pruning data


m_CoverP

private double m_CoverP
The sum of weights of the data covered by this rule in the pruning data


m_CoverG

private double m_CoverG
The accurate and covered data of this rule in the growing data


m_AccuG

private double m_AccuG
The accurate and covered data of this rule in the growing data

Constructor Detail

Ridor.RidorRule

private Ridor.RidorRule()
Method Detail

setPredictedClass

public void setPredictedClass(double cl)
The access functions for parameters


getPredictedClass

public double getPredictedClass()

buildClassifier

public void buildClassifier(Instances instances)
                     throws java.lang.Exception
Builds a single rule learner with REP dealing with 2 classes. This rule learner always tries to predict the class with label m_Class.

Parameters:
instances - the training data
Throws:
java.lang.Exception - if classifier can't be built successfully

coveredByRule

public Instances[] coveredByRule(Instances insts)
Find all the instances in the dataset covered by this rule. The instances not covered will also be deducted from the the original data and returned by this procedure.

Parameters:
insts - the dataset to be covered by this rule.
Returns:
the instances covered and not covered by this rule

isCover

public boolean isCover(Instance datum)
Whether the instance covered by this 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

Returns:
the boolean value indicating whether the rule has antecedents

grow

private void grow(Instances data)
Build one rule using the growing data

Parameters:
data - the growing data used to build the rule

computeInfoGain

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

Parameters:
defAcRt - the default accuracy rate of data
antd - the specific antecedent
Returns:
the data covered by the antecedent

prune

private void prune(Instances pruneData)
Prune the rule using the pruning data and update the worth parameters for this rule The accuracy rate is used to prune the rule.

Parameters:
pruneData - the pruning data used to prune the rule

computeDefAccu

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

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

getWorthRate

public double getWorthRate()
The following are get functions after prune() has set the value of worthRate and worth


getWorth

public double getWorth()

getCoverP

public double getCoverP()

getCoverG

public double getCoverG()

getAccuG

public double getAccuG()

toString

public java.lang.String toString(java.lang.String att,
                                 java.lang.String cl)
Prints this rule with the specified class label

Parameters:
att - the string standing for attribute in the consequent of this rule
cl - the string standing for value in the consequent of this rule
Returns:
a textual description of this rule with the specified class label

toString

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

Returns:
a textual description of this rule