Package weka.classifiers.trees.m5
Class Rule
- java.lang.Object
-
- weka.classifiers.trees.m5.Rule
-
- All Implemented Interfaces:
Serializable,RevisionHandler
public class Rule extends Object implements Serializable, RevisionHandler
Generates a single m5 tree or rule- Version:
- $Revision$
- Author:
- Mark Hall
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Rule()Constructor declaration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildClassifier(Instances data)Generates a single rule or m5 model tree.doubleclassifyInstance(Instance instance)Calculates a prediction for an instance using this rule or M5 model treevoidfreeNotCoveredInstances()Free up memory consumed by the set of instances not covered by this rule.booleangetKuenzelEtAlSplitSelection()Get whether Kuenzel et al.'s split selection is usedRuleNodegetM5RootNode()doublegetMinNumInstances()Get the minimum number of instances to allow at a leaf nodeintgetNumDecimalPlaces()Get the number of decimal places.booleangetRegressionTree()Get the value of regressionTree.StringgetRevision()Returns the revision string.booleangetSmoothing()Get whether or not smoothing has been turned onbooleangetUnpruned()Get whether unpruned tree/rules are being generatedbooleangetUseTree()get whether an m5 tree is being used rather than rulesInstancesnotCoveredInstances()Get the instances not covered by this rulevoidsetKuenzelEtAlSplitSelection(boolean unpruned)Use Kuenzel et al.'s split selectionvoidsetMinNumInstances(double minNum)Set the minumum number of instances to allow at a leaf nodevoidsetNumDecimalPlaces(int num)Set the number of decimal places.voidsetRegressionTree(boolean newregressionTree)Set the value of regressionTree.voidsetSmoothing(boolean s)Smooth predictionsvoidsetUnpruned(boolean unpruned)Use unpruned tree/rulesvoidsetUseTree(boolean u)Use an m5 tree rather than generate rulesRuleNodetopOfTree()Returns the top of the tree.StringtoString()Return a description of the m5 tree or rule
-
-
-
Method Detail
-
buildClassifier
public void buildClassifier(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(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 RuleNode topOfTree()
Returns the top of the tree.
-
toString
public String toString()
Return a description of the m5 tree or rule
-
setKuenzelEtAlSplitSelection
public void setKuenzelEtAlSplitSelection(boolean unpruned)
Use Kuenzel et al.'s split selection- Parameters:
unpruned- true if Kuenzel et al.'s split selection is used
-
getKuenzelEtAlSplitSelection
public boolean getKuenzelEtAlSplitSelection()
Get whether Kuenzel et al.'s split selection is used- Returns:
- true if Kuenzel et al.'s split selection is used
-
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
-
freeNotCoveredInstances
public void freeNotCoveredInstances()
Free up memory consumed by the set of instances not covered by this rule.
-
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
doublevalue
-
getNumDecimalPlaces
public int getNumDecimalPlaces()
Get the number of decimal places.
-
setNumDecimalPlaces
public void setNumDecimalPlaces(int num)
Set the number of decimal places.
-
getM5RootNode
public RuleNode getM5RootNode()
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Returns:
- the revision
-
-