Documentation Center

  • Trial Software
  • Product Updates

resubPredict

Class: RegressionTree

Predict resubstitution response of tree

Syntax

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

Description

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

tree

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.

'subtrees'

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

Yfit

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.

node

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.

Examples

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

See Also

| |

Was this topic helpful?