Yfit = predict(tree,Xdata)
[Yfit,node] = predict(tree,Xdata)
[Yfit,node] = predict(tree,Xdata,Name,Value)
Numeric array with the same number of columns as the array used for creating tree. Each row of Xdata corresponds to one data point, and each column corresponds to one predictor.
Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
Numeric vector of pruning levels, with 0 representing the full, unpruned tree. To use the subtrees name-value pair, tree must include a pruning sequence as created by the RegressionTree.fit or prune methods. If subtrees has T elements, and X has N rows, then Yfit is an N-by-T matrix. The ith column of Yfit contains the fitted values produced by the subtrees(I) subtree. Similarly, node is an N-by-T matrix. subtrees must be sorted in ascending order. (To compute fitted values for a tree that is not part of the optimal pruning sequence, first use prune to prune the tree.)
Find the predicted mileage for a car with 200 cubic inch engine displacement, 150 horsepower, weighing 3000 lbs, based on the carsmall data:
load carsmall X = [Displacement Horsepower Weight]; tree = RegressionTree.fit(X,MPG); Mileage = predict(tree,[200 150 3000]) Mileage = 21.9375