Fit tree
t = treefit(X,y)
t = treefit(X,y,param1
,val1
,param2
,val2
,...)
t = treefit(X,y)
creates
a decision tree t
for predicting response y
as
a function of predictors X
. X
is
an n
bym
matrix of predictor
values. y
is either a vector of n
response
values (for regression), or a character array or cell array of character
vectors containing n
class names (for classification).
Either way, t
is a binary tree where each nonterminal
node is split based on the values of a column of X
.
t = treefit(X,y,
specifies
optional parameter namevalue pairs. Valid parameters are:param1
,val1
,param2
,val2
,...)
The following table lists parameters available for all trees.
Parameter  Value 

'catidx'  Vector of indices of the columns of 
'method'  Either 
'splitmin'  A number 
'prune' 

The following table lists parameters available for classification trees only.
Parameter  Value 

'cost' 

'splitcriterion'  Criterion for choosing a split: either 
'priorprob'  Prior probabilities for each class, specified as a vector
(one value for each distinct group name) or as a structure 
Create a classification tree for Fisher's iris data:
load fisheriris; t = treefit(meas,species); treedisp(t,'names',{'SL' 'SW' 'PL' 'PW'});
[1] Breiman, L., J. Friedman, R. Olshen, and C. Stone. Classification and Regression Trees. Boca Raton, FL: CRC Press, 1984.