Documentation Center

  • Trial Software
  • Product Updates

ClassificationBaggedEnsemble class

Classification ensemble grown by resampling

Description

ClassificationBaggedEnsemble combines a set of trained weak learner models and data on which these learners were trained. It can predict ensemble response for new data by aggregating predictions from its weak learners.

Construction

ens = fitensemble(X,Y,'bag',nlearn,learners,'type','classification') creates a bagged classification ensemble. For syntax details, see the fitensemble reference page.

Properties

CategoricalPredictors

List of categorical predictors. CategoricalPredictors is a numeric vector with indices from 1 to p, where p is the number of columns of X.

CombineWeights

String describing how ens combines weak learner weights, either 'WeightedSum' or 'WeightedAverage'.

FitInfo

Numeric array of fit information. The FitInfoDescription property describes the content of this array.

FitInfoDescription

String describing the meaning of the FitInfo array.

FResample

Numeric scalar between 0 and 1. FResample is the fraction of training data fitensemble resampled at random for every weak learner when constructing the ensemble.

Method

String describing the method that creates ens.

ModelParameters

Parameters used in training ens.

NumTrained

Number of trained weak learners in ens, a scalar.

PredictorNames

Cell array of names for the predictor variables, in the order in which they appear in X.

ReasonForTermination

String describing the reason fitensemble stopped adding weak learners to the ensemble.

Replace

Logical value indicating if the ensemble was trained with replacement (true) or without replacement (false).

ResponseName

String with the name of the response variable Y.

ScoreTransform

Function handle for transforming scores, or string representing a built-in transformation function. 'none' means no transformation; equivalently, 'none' means @(x)x. For a list of built-in transformation functions and the syntax of custom transformation functions, see fitctree.

Add or change a ScoreTransform function using dot notation:

ens.ScoreTransform = 'function'

or

ens.ScoreTransform = @function

Trained

Trained learners, a cell array of compact classification models.

TrainedWeights

Numeric vector of trained weights for the weak learners in ens. TrainedWeights has T elements, where T is the number of weak learners in learners.

UseObsForLearner

Logical matrix of size N-by-NumTrained, where N is the number of observations in the training data and NumTrained is the number of trained weak learners. UseObsForLearner(I,J) is true if observation I was used for training learner J, and is false otherwise.

W

Scaled weights, a vector with length n, the number of rows in X. The sum of the elements of W is 1.

X

Matrix of predictor values that trained the ensemble. Each column of X represents one variable, and each row represents one observation.

Y

A categorical array, cell array of strings, character array, logical vector, or a numeric vector with the same number of rows as X. Each row of Y represents the classification of the corresponding row of X.

Methods

oobEdgeOut-of-bag classification edge
oobLossOut-of-bag classification error
oobMarginOut-of-bag classification margins
oobPredictPredict out-of-bag response of ensemble

Inherited Methods

compactCompact classification ensemble
crossvalCross validate ensemble
resubEdgeClassification edge by resubstitution
resubLossClassification error by resubstitution
resubMarginClassification margins by resubstitution
resubPredictPredict ensemble response by resubstitution
resumeResume training ensemble
edgeClassification edge
lossClassification error
marginClassification margins
predictPredict classification
predictorImportanceEstimates of predictor importance
removeLearnersRemove members of compact classification ensemble

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.

Examples

Construct a bagged ensemble for the ionosphere data, and examine its resubstitution loss:

load ionosphere
rng(0,'twister') % for reproducibility
ens = fitensemble(X,Y,'bag',100,'Tree',...
    'type','classification');
L = resubLoss(ens)

L =
     0

The ensemble does a perfect job classifying its training data.

See Also

| |

How To

Was this topic helpful?