Class: RegressionTree

Predict resubstitution response of tree


Yfit = resubPredict(tree)
[Yfit,node] = resubPredict(tree)
[Yfit,node] = resubPredict(tree,Name,Value)


Yfit = resubPredict(tree) returns the responses tree predicts for the data tree.X. Yfit is the predictions of tree on the data that fitrtree used to create tree.

[Yfit,node] = resubPredict(tree) returns the node numbers of tree for the resubstituted data.

[Yfit,node] = resubPredict(tree,Name,Value) predicts with additional options specified by one or more Name,Value pair arguments.

Input Arguments


A regression tree constructed using fitrtree.

Name-Value Pair Arguments

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.


A vector with integer values from 0 (full unpruned tree) to the maximal pruning level max(tree.PruneList).

Subtrees must be in ascending order.

Default: 0

Output Arguments


The response tree predicts for the training data.

If the Subtrees name-value argument is a scalar or is missing, label is the same data type as the training response data tree.Y.

If Subtrees contains m>1 entries, label has m columns, each of which represents the predictions of the corresponding subtree.


The tree node numbers where tree sends each data row.

If the Subtrees name-value argument is a scalar or is missing, node is a numeric column vector with n rows, the same number of rows as tree.X.

If Subtrees contains m>1 entries, node is a n-by-m matrix. Each column represents the node predictions of the corresponding subtree.


Find the mean square error of a model of the carsmall data:

load carsmall
X = [Displacement Horsepower Weight];
tree = fitrtree(X,MPG);
Yfit = resubPredict(tree);
mean((Yfit - tree.Y).^2)

ans =

You can get the same answer using resubLoss:


ans =
Was this topic helpful?