| 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.treefittreats these columns as unordered categorical values.
 | 
| 'method'
 | Either 'classification'(default ifyis text) or'regression'(default ifyis numeric)
 | 
| 'splitmin'
 | A number nsuch that impure nodes must havenor 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-pmatrixC, whereC(i,j)is the cost of classifying a point into classiif its true class isj(default hasC(i,j)=1ifi~=j, andC(i,j)=0ifi=j).Ccan also be a structureSwith two fields :S.groupcontaining the group names, andS.costcontaining 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 Swith two fields:S.groupcontaining the group names, andS.probcontaining 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 |  |