weka.classifiers.trees.m5
Class Rule2

java.lang.Object
  extended by weka.classifiers.trees.m5.Rule2
All Implemented Interfaces:
Serializable, weka.core.RevisionHandler

public class Rule2
extends Object
implements Serializable, weka.core.RevisionHandler

Generates a single m5 tree or rule

Version:
$Revision: 4584 $
Author:
Mark Hall
See Also:
Serialized Form

Field Summary
protected static int LEFT
           
protected  RuleNode2 m_topOfTree
          the top of the m5 tree for this rule
protected static int RIGHT
           
 
Constructor Summary
Rule2()
          Constructor declaration
 
Method Summary
protected static double absDev(int attr, weka.core.Instances inst)
          Returns the absolute deviation value of the supplied attribute index.
 void buildClassifier(weka.core.Instances data)
          Generates a single rule or m5 model tree.
 double classifyInstance(weka.core.Instance instance)
          Calculates a prediction for an instance using this rule or M5 model tree
 RuleNode2 getM5RootNode()
           
 double getMinNumInstances()
          Get the minimum number of instances to allow at a leaf node
 boolean getRegressionTree()
          Get the value of regressionTree.
 String getRevision()
          Returns the revision string.
 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
 weka.core.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, weka.core.Instances inst)
          Returns the standard deviation value of the supplied attribute index.
 RuleNode2 topOfTree()
          Returns the top of the tree.
 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 RuleNode2 m_topOfTree
the top of the m5 tree for this rule

Constructor Detail

Rule2

public Rule2()
Constructor declaration

Method Detail

buildClassifier

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

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

classifyInstance

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

Parameters:
instance - the instance whos class value is to be predicted
Returns:
the prediction
Throws:
Exception - if a prediction can't be made.

topOfTree

public RuleNode2 topOfTree()
Returns the top of the tree.


toString

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

Overrides:
toString in class Object
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 weka.core.Instances notCoveredInstances()
Get the instances not covered by this rule

Returns:
the instances not covered

stdDev

protected static final double stdDev(int attr,
                                     weka.core.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,
                                     weka.core.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

getM5RootNode

public RuleNode2 getM5RootNode()

getRevision

public String getRevision()
Returns the revision string.

Specified by:
getRevision in interface weka.core.RevisionHandler
Returns:
the revision


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.