yfit = treeval(t,X)
yfit = treeval(t,X,subtrees)
[yfit,node] = treeval(...)
[yfit,node,cname] = treeval(...)
yfit = treeval(t,X) takes
a classification or regression tree
t as produced
treefit function and a matrix
predictor values, and produces a vector
predicted response values. For a regression tree,
the fitted response value for a point having the predictor values
For a classification tree,
yfit(i) is the class
number into which the tree would assign the point with data
To convert the number into a class name, use the third output argument,
yfit = treeval(t,X,subtrees) takes
an additional vector
subtrees of pruning levels,
0 representing the full, unpruned tree.
T must include a pruning sequence as created by the
subtree has k elements and
X has n rows,
yfit is an n-by-k matrix,
jth column containing the fitted values
produced by the
be sorted in ascending order.
[yfit,node] = treeval(...) also
returns an array
node of the same size as
the node number assigned to each row of
can display the node numbers for any node you select.
[yfit,node,cname] = treeval(...) is
valid only for classification trees. It returns a cell array
the predicted class names.
Find the predicted classifications for Fisher's iris data:
load fisheriris; t = treefit(meas,species); % Create decision tree sfit = treeval(t,meas); % Find assigned class numbers sfit = t.classname(sfit); % Get class names mean(strcmp(sfit,species)) % Proportion in correct class ans = 0.9800
 Breiman, L., J. Friedman, R. Olshen, and C. Stone. Classification and Regression Trees. Boca Raton, FL: CRC Press, 1984.