oobPredict

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 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. (The software treats string arrays as cell arrays of character vectors.) 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.

[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 = 16

More About

expand all