public class Tree extends Object implements Serializable, Cloneable
| Constructor and Description |
|---|
Tree(int nRows,
int minObsAllowedInChild,
int maxNumberOfCategories,
int maxNumberOfNodes,
int nClasses,
int nPreds,
PredictiveModel.VariableType varType,
int[] predNValues,
PredictiveModel.VariableType[] predType,
int nyMissing)
Creates the root node of a decision tree and contains information about
the relationship of child nodes.
|
| Modifier and Type | Method and Description |
|---|---|
protected Tree |
clone()
Returns a clone of this object.
|
TreeNode |
getNode(int i)
Returns a copy of the specified node of the decision tree.
|
TreeNode[] |
getNodes()
Returns nodes within a decision tree.
|
int |
getNumberOfClasses()
Returns the number of classes assumed by the response variable, if the
response variable is categorical.
|
int |
getNumberOfLevels()
Returns the number of levels or depth of a tree.
|
int |
getNumberOfNodes()
Returns the number of nodes (size of a tree).
|
int |
getNumberOfPredictors()
Returns the number of predictors used in the model.
|
int |
getNumberOfSurrogateSplits()
Returns the number of surrogate splits searched for at each tree node.
|
int[] |
getPredictorNumberOfValues()
Returns the number of distinct values of each predictor variable.
|
PredictiveModel.VariableType |
getPredictorType(int i)
Returns the
PredictiveModel.VariableType of a
predictor variable. |
PredictiveModel.VariableType |
getResponseType()
Returns the
PredictiveModel.VariableType of
the response variable. |
boolean[] |
getTerminalNodeIndicators()
Returns the terminal node indicator array.
|
boolean |
isTerminalNode(int i)
Returns the terminal node indicator of the node at the given index.
|
void |
setNode(int i,
TreeNode dtn)
Inserts a
TreeNode into the specified location of the
decision tree. |
void |
setNodes(TreeNode[] nodes)
Sets the nodes within a decision tree.
|
void |
setNumberOfLevels(int nLevels)
Sets the number of levels determined for a tree (depth).
|
void |
setNumberOfNodes(int nNodes)
Sets the number of nodes (size of a tree).
|
void |
setNumberOfSurrogateSplits(int nSurrogates)
Sets the number of surrogate splits to search for at each tree node.
|
void |
setTerminalNode(int i,
boolean terminalNode)
Sets the terminal node indicator of the node at the given index.
|
void |
setTerminalNodeIndicators(boolean[] terminalNodes)
Sets the terminal node indicator array.
|
public Tree(int nRows,
int minObsAllowedInChild,
int maxNumberOfCategories,
int maxNumberOfNodes,
int nClasses,
int nPreds,
PredictiveModel.VariableType varType,
int[] predNValues,
PredictiveModel.VariableType[] predType,
int nyMissing)
nRows - an int indicating the number of observations
(rows) in the input data.minObsAllowedInChild - an int indicating the number of
observations necessary in all potential child nodes before a node may be
split.maxNumberOfCategories - an int indicating the maximum
number of categories allowed for categorical predictor variables.maxNumberOfNodes - an int indicating the maximum number
of nodes allowed in the tree.nClasses - an int indicating the number of classes
assumed by the response variable, if the response variable is
categorical.nPreds - an int indicating the number of predictors
used in the model.varType - a PredictiveModel.VariableType
array of length equal to the number of variables active in the model,
which is less than or equal to the available columns in the data,
(xy[i].length).predNValues - an int array containing the number of
values of each predictor variable.predType - a
PredictiveModel.VariableType array of length
equal to the number of predictors containing the type of each predictor
variable.nyMissing - an int equal to the number of missing
values in the response variable.protected Tree clone()
public TreeNode getNode(int i)
i - an int that specifies the index of a
TreeNode to be returned.TreeNode corresponding to the specified index.public TreeNode[] getNodes()
TreeNode array containing a copy of the
TreeNodes within the decision tree.public int getNumberOfClasses()
intequal to the number of classes assumed by the
response variable, if the response variable is categorical.public int getNumberOfLevels()
int specifying the number of levels or depth of a
tree.public int getNumberOfNodes()
int specifying the number of nodes in a tree
(size).public int getNumberOfPredictors()
int equal to the number of predictors used in the
model.public int getNumberOfSurrogateSplits()
Surrogate splits are only relevant for classes which implement the
com.imsl.datamining.decisionTree.DecisionTreeSurrogateMethod
interface.
int equal to the number of surrogate splits
searched for at each node.public int[] getPredictorNumberOfValues()
Note that if the predictor is
com.imsl.datamining.PredictiveModel.VariableType.QUANTITATIVE_CONTINUOUS,
the corresponding value in the array is set to 0.
int array containing the number of values of each
predictor variable.public PredictiveModel.VariableType getPredictorType(int i)
PredictiveModel.VariableType of a
predictor variable.i - an int specifying the predictor.VariableType equal to the variable type of the
predictor at index i.public PredictiveModel.VariableType getResponseType()
PredictiveModel.VariableType of
the response variable.PredictiveModel.VariableType that indicates the
response variable type.public boolean[] getTerminalNodeIndicators()
boolean array indicating which nodes are terminal
nodes and which are not. If true at index i,
then the node at index i is a terminal node.public boolean isTerminalNode(int i)
i - an int which indicates what node to query.boolean indicating whether the specified node is a
terminal node or not.public void setNode(int i,
TreeNode dtn)
TreeNode into the specified location of the
decision tree.i - an int indicating the index for insertion of a
TreeNode.dtn - a TreeNode to be inserted into the decision tree.public void setNodes(TreeNode[] nodes)
nodes - a TreeNode array specifying
TreeNodes within the decision tree.public void setNumberOfLevels(int nLevels)
nLevels - an int indicating the number of levels
determined for a tree (depth).
nLevels must be nonnegative.
Default: nLevels = 0
public void setNumberOfNodes(int nNodes)
nNodes - an int specifying the number of nodes in a
tree (size).
nNodes must be nonnegative.
Default: nNodes = 0
public void setNumberOfSurrogateSplits(int nSurrogates)
Surrogate splits are only relevant for classes which implement the
com.imsl.datamining.decisionTree.DecisionTreeSurrogateMethod
interface.
nSurrogates - an int specifying the number of surrogate
splits to search for at each tree node.
nSurrogates must be nonnegative and less than the number of
predictors - 1.
Default: nSurrogates = 0
public void setTerminalNode(int i,
boolean terminalNode)
i - an int which indicates which node.terminalNode - a boolean indicating whether the
specified node is a terminal node or not (true for a
terminal node false otherwise).
Default: terminalNode = false.
public void setTerminalNodeIndicators(boolean[] terminalNodes)
terminalNodes - a boolean array of terminal node
designations. If true at index i, then the node
at index i is a terminal node.
Default: terminalNodes[i] = false.
Copyright © 1970-2015 Rogue Wave Software
Built March 24 2015.