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: 15357 $
- Author:
- Mark Hall (mhall@cs.waikato.ac.nz)
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionint
the 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
buildClassifier
(Instances data) Build this node (find an attribute and split point)double
classifyInstance
(Instance inst) Classify an instance using this node.void
findBestLeaf
(double[] maxCoverage, RuleNode[] bestLeaf) Find the leaf with greatest coveragedouble
Get the minimum number of instances to allow at a leaf nodegetModel()
Get the linear model at this nodeint
Return the number of instances that reach this node.boolean
Get the value of regressionTree.Returns the revision string.void
graph
(StringBuffer text) Assign a unique identifier to each node in the tree and then calls graphTreevoid
Traverses the tree and installs linear models at each node.void
boolean
isLeaf()
Return true if this node is a leafleftNode()
Get the left child of this nodeReturns a description of this node (debugging purposes)int
Get the number of linear models in the treeint
numLeaves
(int leafCounter) Sets the leaves' numbersGet the parent of this nodevoid
Print all the linear models at the learf (debugging purposes)print all leaf modelsprint the linear model at this nodevoid
prune()
Recursively prune the treevoid
returnLeaves
(ArrayList<RuleNode>[] v) Return a list containing all the leaves in the treeGet the right child of this nodevoid
setMinNumInstances
(double minNum) Set the minumum number of instances to allow at a leaf nodevoid
setRegressionTree
(boolean newregressionTree) Set the value of regressionTree.void
split()
Finds an attribute and split point for this nodeint
splitAtt()
Get the index of the splitting attribute for this nodedouble
splitVal()
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 newRuleNode
instance.- 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:
classifyInstance
in interfaceClassifier
- Overrides:
classifyInstance
in 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
double
value
-
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
- aStringBuffer
value
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classAbstractClassifier
- Returns:
- the revision
-