Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

oobPredict

Class: ClassificationBaggedEnsemble

Predict out-of-bag response of ensemble

Syntax

[label,score] = oobPredict(ens)
[label,score] = oobPredict(ens,Name,Value)

Description

[label,score] = oobPredict(ens) returns class labels and scores for ens for out-of-bag data.

[label,score] = oobPredict(ens,Name,Value) computes labels and scores with additional options specified by one or more Name,Value pair arguments.

Input Arguments

ens

A classification bagged ensemble, constructed with fitcensemble.

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.

'learners'

Indices of weak learners in the ensemble ranging from 1 to ens.NumTrained. oobEdge uses only these learners for calculating loss.

Default: 1:NumTrained

Output Arguments

label

Classification labels of the same data type as the training data Y. There are N elements or rows, where N is the number of training observations. The label is the class with the highest score. In case of a tie, the label is earliest in ens.ClassNames.

score

An N-by-K numeric matrix for N observations and K classes. A high score indicates that an observation is likely to come from this class. Scores are in the range 0 to 1.

Examples

expand all

Find the out-of-bag predictions and scores for the Fisher iris data. Find the scores with notable uncertainty in the resulting classifications.

Load the sample data set.

load fisheriris

Train an ensemble of bagged classification trees.

ens = fitcensemble(meas,species,'Method','Bag');

Find the out-of-bag predictions and scores.

rng(10,'twister') % For reproducibility
[label,score] = oobPredict(ens);

Find the scores in the range (0.2,0.8). These scores have notable uncertainty in the resulting classifications.

unsure = ((score > .2) & (score < .8));
sum(sum(unsure))  % Number of uncertain predictions
ans = 18

Definitions

expand all

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?