weka.classifiers.trees.m5
Class Rule

java.lang.Object
  extended byweka.classifiers.trees.m5.Rule

public class Rule
extends java.lang.Object

Generates a single m5 tree or rule


Field Summary
protected static int LEFT
           
protected  RuleNode m_topOfTree
          the top of the m5 tree for this rule
protected static int RIGHT
           
 
Constructor Summary
Rule()
          Constructor declaration
 
Method Summary
protected static double absDev(int attr, Instances inst)
          Returns the absolute deviation value of the supplied attribute index.
 void buildClassifier(Instances data)
          Generates a single rule or m5 model tree.
 double classifyInstance(Instance instance)
          Calculates a prediction for an instance using this rule or M5 model tree
 double getMinNumInstances()
          Get the minimum number of instances to allow at a leaf node
 boolean getRegressionTree()
          Get the value of regressionTree.
 boolean getSmoothing()
          Get whether or not smoothing has been turned on
 boolean getUnpruned()
          Get whether unpruned tree/rules are being generated
 boolean getUseTree()
          get whether an m5 tree is being used rather than rules
 Instances notCoveredInstances()
          Get the instances not covered by this rule
 void setMinNumInstances(double minNum)
          Set the minumum number of instances to allow at a leaf node
 void setRegressionTree(boolean newregressionTree)
          Set the value of regressionTree.
protected  void setSaveInstances(boolean save)
          Sets whether instances at each node in an M5 tree should be saved for visualization purposes.
 void setSmoothing(boolean s)
          Smooth predictions
 void setUnpruned(boolean unpruned)
          Use unpruned tree/rules
 void setUseTree(boolean u)
          Use an m5 tree rather than generate rules
protected static double stdDev(int attr, Instances inst)
          Returns the standard deviation value of the supplied attribute index.
 java.lang.String toString()
          Return a description of the m5 tree or rule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT

protected static int LEFT

RIGHT

protected static int RIGHT

m_topOfTree

protected RuleNode m_topOfTree
the top of the m5 tree for this rule

Constructor Detail

Rule

public Rule()
Constructor declaration

Method Detail

buildClassifier

public void buildClassifier(Instances data)
                     throws java.lang.Exception
Generates a single rule or m5 model tree.

Parameters:
data - set of instances serving as training data
Throws:
java.lang.Exception - if the rule has not been generated successfully

classifyInstance

public double classifyInstance(Instance instance)
                        throws java.lang.Exception
Calculates a prediction for an instance using this rule or M5 model tree

Returns:
the prediction
Throws:
if - a prediction can't be made.
java.lang.Exception

toString

public java.lang.String toString()
Return a description of the m5 tree or rule

Returns:
a description of the m5 tree or rule as a String

setUnpruned

public void setUnpruned(boolean unpruned)
Use unpruned tree/rules

Parameters:
unpruned - true if unpruned tree/rules are to be generated

getUnpruned

public boolean getUnpruned()
Get whether unpruned tree/rules are being generated

Returns:
true if unpruned tree/rules are to be generated

setUseTree

public void setUseTree(boolean u)
Use an m5 tree rather than generate rules

Parameters:
u - true if m5 tree is to be used

getUseTree

public boolean getUseTree()
get whether an m5 tree is being used rather than rules

Returns:
true if an m5 tree is being used.

setSmoothing

public void setSmoothing(boolean s)
Smooth predictions

Parameters:
s - true if smoothing is to be used

getSmoothing

public boolean getSmoothing()
Get whether or not smoothing has been turned on

Returns:
true if smoothing is being used

notCoveredInstances

public Instances notCoveredInstances()
Get the instances not covered by this rule

Returns:
the instances not covered

stdDev

protected static final double stdDev(int attr,
                                     Instances inst)
Returns the standard deviation value of the supplied attribute index.

Parameters:
attr - an attribute index
inst - the instances
Returns:
the standard deviation value

absDev

protected static final double absDev(int attr,
                                     Instances inst)
Returns the absolute deviation value of the supplied attribute index.

Parameters:
attr - an attribute index
inst - the instances
Returns:
the absolute deviation value

setSaveInstances

protected void setSaveInstances(boolean save)
Sets whether instances at each node in an M5 tree should be saved for visualization purposes. Default is to save memory.

Parameters:
save - a boolean value

getRegressionTree

public boolean getRegressionTree()
Get the value of regressionTree.

Returns:
Value of regressionTree.

setRegressionTree

public void setRegressionTree(boolean newregressionTree)
Set the value of regressionTree.

Parameters:
newregressionTree - Value to assign to regressionTree.

setMinNumInstances

public void setMinNumInstances(double minNum)
Set the minumum number of instances to allow at a leaf node

Parameters:
minNum - the minimum number of instances

getMinNumInstances

public double getMinNumInstances()
Get the minimum number of instances to allow at a leaf node

Returns:
a double value