Statistics Toolbox |
 |
treefit
Fit a tree-based model for classification or regression
Syntax
T = treefit(X,y)
T = treefit(X,y,'param1',val1,'param2',val2,...)
Description
T = treefit(X,y)
creates a decision tree T
for predicting response y
as a function of predictors X
. X
is an n
-by-m
matrix of predictor values. y
is either a vector of n
response values (for regression), or a character array or cell array of strings containing n
class names (for classification). Either way, T
is a binary tree where each non-terminal node is split based on the values of a column of X
.
T = treefit(X,y,'param1',val1,'param2',val2,...)
specifies optional parameter name-value pairs. Valid parameters are
For all trees:
'catidx'
|
Vector of indices of the columns of X . treefit treats these columns as unordered categorical values.
|
'method'
|
Either 'classification' (default if y is text) or 'regression' (default if y is numeric)
|
'splitmin'
|
A number n such that impure nodes must have n or more observations to be split (default 10)
|
'prune'
|
'on' (default) to compute the full tree and a sequence of pruned subtrees, or 'off' for the full tree without pruning
|
For classification trees only:
'cost'
|
p -by-p matrix C , where C(i,j) is the cost of classifying a point into class i if its true class is j (default has C(i,j)=1 if i~=j , and C(i,j)=0 if i=j ). C can also be a structure S with two fields : S.group containing the group names, and S.cost containing a matrix of cost values.
|
'splitcriterion'
|
Criterion for choosing a split: either 'gdi' (default) for Gini's diversity index, 'twoing' for the twoing rule, or 'deviance' for maximum deviance reduction
|
'priorprob'
|
Prior probabilities for each class, specified as a vector (one value for each distinct group name) or as a structure S with two fields: S.group containing the group names, and S.prob containing a vector of corresponding probabilities
|
Examples
Create a classification tree for Fisher's iris data.
See Also
treedisp
, treetest
References
[1] Breiman, et al., Classification and Regression Trees, Chapman and Hall,
Boca Raton, 1993.
| treedisp | | treeprune |  |