Yfit = resubPredict(tree)
[Yfit,node] = resubPredict(tree)
[Yfit,node] = resubPredict(tree,Name,Value)
A regression tree constructed using fitrtree.
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.
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 = 4.8952
You can get the same answer using resubLoss:
resubLoss(tree) ans = 4.8952