Quantcast

Documentation Center

  • Trial Software
  • Product Updates

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 fitensemble.

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.

Definitions

Out of Bag

Bagging, which stands for "bootstrap aggregation", is a type of ensemble learning. To bag a weak learner such as a decision tree on a dataset, fitensemble generates many bootstrap replicas of the dataset and grows decision trees on these replicas. fitensemble obtains each bootstrap replica by randomly selecting N observations out of N with replacement, where N is the dataset size. To find the predicted response of a trained ensemble, predict take an average over predictions from individual trees.

Drawing N out of N observations with replacement omits on average 37% (1/e) of observations for each decision tree. These are "out-of-bag" observations. For each observation, oobLoss estimates the out-of-bag prediction by averaging over predictions from all trees in the ensemble for which this observation is out of bag. It then compares the computed prediction against the true response for this observation. It calculates the out-of-bag error by comparing the out-of-bag predicted responses against the true responses for all observations used for training. This out-of-bag average is an unbiased estimator of the true ensemble error.

Score (ensemble)

For ensembles, a classification score represents the confidence of a classification into a class. The higher the score, the higher the confidence.

Different ensemble algorithms have different definitions for their scores. Furthermore, the range of scores depends on ensemble type. For example:

  • AdaBoostM1 scores range from –∞ to ∞.

  • Bag scores range from 0 to 1.

Examples

Find the out-of-bag predictions and scores for the Fisher iris data. Find the scores in the range (0.2,0.8); these are the scores where there is notable uncertainty in the resulting classifications.

load fisheriris
ens = fitensemble(meas,species,'Bag',100,...
    'Tree','type','classification');
[label score] = oobPredict(ens);
unsure = ( (score > .2) & (score < .8));
sum(sum(unsure)) % How many uncertain predictions?

ans =
    16

See Also

| | | |

Was this topic helpful?