Documentation

ClassificationEnsemble class

Superclasses: CompactClassificationEnsemble

Ensemble classifier

Description

ClassificationEnsemble 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. It also stores data used for training and can compute resubstitution predictions. It can resume training if desired.

Construction

ens = fitensemble(X,Y,method,nlearn,learners) returns an ensemble model that can predict responses to data. The ensemble consists of models listed in learners. For more information on the syntax, see the fitensemble function reference page.

ens = fitensemble(X,Y,method,nlearn,learners,Name,Value) returns an ensemble model with additional options specified by one or more Name,Value pair arguments. For more information on the syntax, see the fitensemble function 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.

ClassNames

List of the elements in Y with duplicates removed. ClassNames can be a numeric vector, categorical vector, logical vector, character array, or cell array of strings. ClassNames has the same data type as the data in the argument Y.

CombineWeights

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

Cost

Square matrix where Cost(i,j) is the cost of classifying a point into class j if its true class is i.

FitInfo

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

FitInfoDescription

String describing the meaning of the FitInfo array.

LearnerNames

Cell array of strings with names of weak learners in the ensemble. The name of each learner appears just once. For example, if you have an ensemble of 100 trees, LearnerNames is {'Tree'}.

Method

String describing the method that creates ens.

ModelParameters

Parameters used in training ens.

NumObservations

Numeric scalar containing the number of observations in the training data.

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.

Prior

Prior probabilities for each class. Prior is a numeric vector whose entries relate to the corresponding ClassNames property.

ReasonForTermination

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

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.

UsePredForLearner

Logical matrix of size P-by-NumTrained, where P is the number of predictors (columns) in the training data X. UsePredForLearner(i,j) is true when learner j uses predictor i, and is false otherwise. For each learner, the predictors have the same order as the columns in the training data X.

If the ensemble is not of type Subspace, all entries in UsePredForLearner are true.

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

Numeric vector, categorical vector, logical vector, character array, or cell array of strings. Each row of Y represents the classification of the corresponding row of X.

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

Inherited Methods

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 boosted classification ensemble for the ionosphere data, using the AdaBoostM1 method:

load ionosphere
ens = fitensemble(X,Y,'AdaBoostM1',100,'Tree')
ens = 

  classreg.learning.classif.ClassificationEnsemble
          PredictorNames: {1x34 cell}
            ResponseName: 'Y'
              ClassNames: {'b'  'g'}
          ScoreTransform: 'none'
         NumObservations: 351
              NumTrained: 100
                  Method: 'AdaBoostM1'
            LearnerNames: {'Tree'}
    ReasonForTermination: 'Terminated normally after comp...'
                 FitInfo: [100x1 double]
      FitInfoDescription: {2x1 cell}


  Properties, Methods

Predict the classification of the mean of X:

ypredict = predict(ens,mean(X))
ypredict = 
    'g'
Was this topic helpful?