Documentation

oobPredict

Class: TreeBagger

Ensemble predictions for out-of-bag observations

Syntax

Y = oobPredict(B)
Y = oobPredict(B,'param1',val1,'param2',val2,...)

Description

Y = oobPredict(B) computes predicted responses using the trained bagger B for out-of-bag observations in the training data. The output has one prediction for each observation in the training data. The returned Y is a cell array of strings for classification and a numeric array for regression.

Y = oobPredict(B,'param1',val1,'param2',val2,...) specifies optional parameter name/value pairs:

'Trees'Array of tree indices to use for computation of responses. Default is 'all'.
'TreeWeights'Array of NTrees weights for weighting votes from the specified trees.

Algorithms

oobPredict and predict similarly predict classes and responses.

  • In regression problems:

    • For each observation that is out of bag for at least one tree, oobPredict composes the weighted mean by selecting responses of trees in which the observation is out of bag. For this computation, the 'TreeWeights' name-value pair argument specifies the weights.

    • For each observation that is in bag for all trees, the predicted response is the weighted mean of all of the training responses. For this computation, the W property of the TreeBagger model (i.e., the observation weights) specify the weights.

  • In classification problems:

    • For each observation that is out of bag for at least one tree, oobPredict composes the weighted mean of the class posterior probabilities by selecting the trees in which the observation is out of bag. Consequently, the predicted class is the class corresponding to the largest weighted mean. For this computation, the 'TreeWeights' name-value pair argument specifies the weights.

    • For each observation that is in bag for all trees, the predicted class is the weighted, most popular class over all training responses. For this computation, the W property of the TreeBagger model (i.e., the observation weights) specify the weights. If there are multiple most popular classes, oobPredict considers the one listed first in the ClassNames property of the TreeBagger model the most popular.

Was this topic helpful?