Package weka.classifiers.trees.m5
Class Rule2
- java.lang.Object
-
- 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$
- Author:
- Mark Hall
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
LEFT
protected RuleNode2
m_topOfTree
the top of the m5 tree for this ruleprotected static int
RIGHT
-
Constructor Summary
Constructors Constructor Description Rule2()
Constructor declaration
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 treeRuleNode2
getM5RootNode()
double
getMinNumInstances()
Get the minimum number of instances to allow at a leaf nodeboolean
getRegressionTree()
Get the value of regressionTree.String
getRevision()
Returns the revision string.boolean
getSmoothing()
Get whether or not smoothing has been turned onboolean
getUnpruned()
Get whether unpruned tree/rules are being generatedboolean
getUseTree()
get whether an m5 tree is being used rather than rulesweka.core.Instances
notCoveredInstances()
Get the instances not covered by this rulevoid
setMinNumInstances(double minNum)
Set the minumum number of instances to allow at a leaf nodevoid
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 predictionsvoid
setUnpruned(boolean unpruned)
Use unpruned tree/rulesvoid
setUseTree(boolean u)
Use an m5 tree rather than generate rulesprotected 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
-
-
-
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
-
-
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
-
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 indexinst
- 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 indexinst
- 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
- aboolean
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 interfaceweka.core.RevisionHandler
- Returns:
- the revision
-
-