Package weka.classifiers.trees.m5
Class RuleNode
java.lang.Object
weka.classifiers.AbstractClassifier
weka.classifiers.trees.m5.RuleNode
- All Implemented Interfaces:
Serializable,Cloneable,Classifier,BatchPredictor,CapabilitiesHandler,CapabilitiesIgnorer,CommandlineRunnable,OptionHandler,RevisionHandler
Constructs a node for use in an m5 tree or rule
- Version:
- $Revision: 15358 $
- Author:
- Mark Hall (mhall@cs.waikato.ac.nz)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionintthe number of paramters in the chosen model for this node---either the subtree model or the linear model.Fields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbuildClassifier(Instances data) Build this node (find an attribute and split point)doubleclassifyInstance(Instance inst) Classify an instance using this node.voidfindBestLeaf(double[] maxCoverage, RuleNode[] bestLeaf) Find the leaf with greatest coveragedoubleGet the minimum number of instances to allow at a leaf nodegetModel()Get the linear model at this nodeintReturn the number of instances that reach this node.booleanGet the value of regressionTree.Returns the revision string.voidgraph(StringBuffer text) Assign a unique identifier to each node in the tree and then calls graphTreevoidTraverses the tree and installs linear models at each node.voidbooleanisLeaf()Return true if this node is a leafleftNode()Get the left child of this nodeReturns a description of this node (debugging purposes)intGet the number of linear models in the treeintnumLeaves(int leafCounter) Sets the leaves' numbersGet the parent of this nodevoidPrint all the linear models at the learf (debugging purposes)print all leaf modelsprint the linear model at this nodevoidprune()Recursively prune the treevoidreturnLeaves(ArrayList<RuleNode>[] v) Return a list containing all the leaves in the treeGet the right child of this nodevoidsetMinNumInstances(double minNum) Set the minumum number of instances to allow at a leaf nodevoidsetRegressionTree(boolean newregressionTree) Set the value of regressionTree.voidsplit()Finds an attribute and split point for this nodeintsplitAtt()Get the index of the splitting attribute for this nodedoublesplitVal()Get the split point for this nodetoString()print the linear model at this nodetreeToString(int level) Recursively builds a textual description of the treeMethods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, debugTipText, distributionForInstance, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getCapabilities, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, getOptions, implementsMoreEfficientBatchPrediction, listOptions, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces, setOptions
-
Field Details
-
m_numParameters
public int m_numParametersthe number of paramters in the chosen model for this node---either the subtree model or the linear model. The constant term is counted as a paramter---this is for pruning purposes
-
-
Constructor Details
-
RuleNode
Creates a newRuleNodeinstance.- Parameters:
globalDev- the global standard deviation of the classglobalAbsDev- the global absolute deviation of the classparent- the parent of this node
-
-
Method Details
-
buildClassifier
Build this node (find an attribute and split point)- Parameters:
data- the instances on which to build this node- Throws:
Exception- if an error occurs
-
classifyInstance
Classify an instance using this node. Recursively calls classifyInstance on child nodes.- Specified by:
classifyInstancein interfaceClassifier- Overrides:
classifyInstancein classAbstractClassifier- Parameters:
inst- the instance to classify- Returns:
- the prediction for this instance
- Throws:
Exception- if an error occurs
-
split
Finds an attribute and split point for this node- Throws:
Exception- if an error occurs
-
numLeaves
public int numLeaves(int leafCounter) Sets the leaves' numbers- Parameters:
leafCounter- the number of leaves counted- Returns:
- the number of the total leaves under the node
-
toString
print the linear model at this node -
printNodeLinearModel
print the linear model at this node- Returns:
- the linear model at this node
-
printLeafModels
print all leaf models- Returns:
- the leaf models
-
nodeToString
Returns a description of this node (debugging purposes)- Returns:
- a string describing this node
-
treeToString
Recursively builds a textual description of the tree- Parameters:
level- the level of this node- Returns:
- string describing the tree
-
installLinearModels
Traverses the tree and installs linear models at each node. This method must be called if pruning is not to be performed.- Throws:
Exception- if an error occurs
-
installSmoothedModels
- Throws:
Exception
-
prune
Recursively prune the tree- Throws:
Exception- if an error occurs
-
findBestLeaf
Find the leaf with greatest coverage- Parameters:
maxCoverage- the greatest coverage found so farbestLeaf- the leaf with the greatest coverage
-
returnLeaves
Return a list containing all the leaves in the tree- Parameters:
v- a single element array containing a vector of leaves
-
parentNode
Get the parent of this node- Returns:
- the parent of this node
-
leftNode
Get the left child of this node- Returns:
- the left child of this node
-
rightNode
Get the right child of this node- Returns:
- the right child of this node
-
splitAtt
public int splitAtt()Get the index of the splitting attribute for this node- Returns:
- the index of the splitting attribute
-
splitVal
public double splitVal()Get the split point for this node- Returns:
- the split point for this node
-
numberOfLinearModels
public int numberOfLinearModels()Get the number of linear models in the tree- Returns:
- the number of linear models
-
isLeaf
public boolean isLeaf()Return true if this node is a leaf- Returns:
- true if this node is a leaf
-
getModel
Get the linear model at this node- Returns:
- the linear model at this node
-
getNumInstances
public int getNumInstances()Return the number of instances that reach this node.- Returns:
- the number of instances at this node.
-
getRegressionTree
public boolean getRegressionTree()Get the value of regressionTree.- Returns:
- Value of 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
-
setRegressionTree
public void setRegressionTree(boolean newregressionTree) Set the value of regressionTree.- Parameters:
newregressionTree- Value to assign to regressionTree.
-
printAllModels
public void printAllModels()Print all the linear models at the learf (debugging purposes) -
graph
Assign a unique identifier to each node in the tree and then calls graphTree- Parameters:
text- aStringBuffervalue
-
getRevision
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classAbstractClassifier- Returns:
- the revision
-