Predict response of regression tree
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 fitrtree 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 = fitrtree(X,MPG); Mileage = predict(tree,[200 150 3000]) Mileage = 21.9375