Categories &

Functions List

Class Definition: ClassificationEnsemble

statistics: ClassificationEnsemble

Boosted ensemble of decision trees for classification

A ClassificationEnsemble object holds the weak learners a boosting method grew one after another, each on the observations reweighted by the errors of those before it, together with the data it was fitted on. AdaBoostM1, GentleBoost and LogitBoost fit two classes, AdaBoostM2 more than two.

Create one with fitcensemble. A bagged ensemble is a ClassificationBaggedEnsemble, and compact returns a CompactClassificationEnsemble without the data.

See also: fitcensemble, CompactClassificationEnsemble, ClassificationBaggedEnsemble

Source Code: ClassificationEnsemble

The ClassificationEnsemble class contains the following properties:

The predictors the ensemble was fitted on, one row per observation, a row missing a value or a class having been left out. This property is read-only.

The labels the ensemble was fitted on, in the type they were given in. This property is read-only.

A logical column over the rows as supplied. This property is read-only.

The weights given, scaled so that the observations of each class sum to its prior probability. A cost matrix is not folded into them. This property is read-only.

A structure with the fields Type, Method, LearnerTemplates, the tree template the learners were grown from, NLearn, the number of learning cycles asked for in all, and LearnRate. This property is read-only.

This property is read-only.

Always empty, binning not being implemented. This property is read-only.

Always empty, such optimization not being implemented. This property is read-only.

A cell array of character vectors. This property is read-only.

The predictors every tree treats as categorical, empty when none is. This property is read-only.

This property is read-only.

The same as PredictorNames. This property is read-only.

The classes, in the type of the response, sorted or in the order given by the 'ClassNames' option; the columns of the scores take them in that order. This property is read-only.

A row vector with one probability per class. This property is read-only.

A square matrix, Cost(i,j) being the cost of classifying an observation of class i as class j. A boosting method starts from observation weights multiplied by the total cost of misclassifying each observation’s class. This property is read-only.

'AdaBoostM1', 'AdaBoostM2', 'GentleBoost', 'LogitBoost', 'RUSBoost', 'LPBoost', 'TotalBoost', 'Bag' or 'Subspace'. This property is read-only.

{'Tree'}, or for Subspace {'KNN'} or {'Discriminant'}. This property is read-only.

A character vector. This property is read-only.

A column with one element per learner: the weighted classification error for AdaBoostM1, the weighted pseudo-loss for AdaBoostM2 and RUSBoost, and the weighted mean squared error of the regression tree for GentleBoost and LogitBoost. For LPBoost and TotalBoost a matrix with a row per learner: its margin on each observation, and its edge last. Empty for Bag. This property is read-only.

This property is read-only.

For the 'Subspace' method, a logical matrix with one row per predictor and one column per learner. Empty for tree learners, as MATLAB returns it. This property is read-only.

This property is read-only.

A column cell array of compact trees, as described under CompactClassificationEnsemble.Trained. This property is read-only.

A column with one weight per learner. This property is read-only.

'WeightedSum' for boosting, 'WeightedAverage' for Bag. This property is read-only.

See CompactClassificationEnsemble.ScoreTransform.

The ClassificationEnsemble class offers the following public methods:

ClassificationEnsemble: obj = ClassificationEnsemble (X, Y)
ClassificationEnsemble: obj = ClassificationEnsemble (…, name, value)

fitcensemble is the documented way in, and its help lists the options both take. A bagged ensemble is fitted by ClassificationBaggedEnsemble.

See also: fitcensemble, ClassificationBaggedEnsemble

ClassificationEnsemble: CVMdl = crossval (obj)
ClassificationEnsemble: CVMdl = crossval (…, name, value)

CVMdl = crossval (obj) refits the ensemble on the training part of each of ten folds, stratified by class, and returns a ClassificationPartitionedEnsemble. One of 'KFold', an integer greater than 1, 'Holdout', a number between 0 and 1, 'Leaveout', 'on' for one fold per observation, or 'CVPartition', a cvpartition object, may choose the partition instead.

See also: ClassificationEnsemble, ClassificationPartitionedEnsemble, cvpartition

ClassificationEnsemble: CMdl = compact (obj)

CMdl = compact (obj) returns a CompactClassificationEnsemble holding the learners and what prediction needs. It predicts new data identically.

See also: ClassificationEnsemble, CompactClassificationEnsemble

ClassificationEnsemble: B = resume (obj, NumLearningCycles)
ClassificationEnsemble: B = resume (…, ’NPrint’, n)

B is the ensemble with up to NumLearningCycles further learners grown as though the fit had asked for them from the start: the boosting weights carry on from where it stopped. An ensemble whose fit ended on a learner that classified the data perfectly grows no more. 'NPrint' is taken as by fitcensemble.

MATLAB R2024a restarts the mislabel weights of AdaBoostM2 on a resume, so its learner weights then differ from those of one longer fit; here they are the same.

See also: ClassificationEnsemble, fitcensemble

ClassificationEnsemble: label = predict (obj, X)
ClassificationEnsemble: [label, scores] = predict (…)
ClassificationEnsemble: […] = predict (…, name, value)

Behaves as CompactClassificationEnsemble.predict and takes the same Name-Value arguments.

See also: ClassificationEnsemble, CompactClassificationEnsemble.predict

ClassificationEnsemble: L = loss (obj, X, Y)
ClassificationEnsemble: L = loss (…, name, value)

Behaves as CompactClassificationEnsemble.loss and takes the same Name-Value arguments.

See also: ClassificationEnsemble, CompactClassificationEnsemble.loss

ClassificationEnsemble: e = edge (obj, X, Y)
ClassificationEnsemble: e = edge (…, name, value)

Behaves as CompactClassificationEnsemble.edge and takes the same Name-Value arguments.

See also: ClassificationEnsemble, CompactClassificationEnsemble.edge

ClassificationEnsemble: m = margin (obj, X, Y)
ClassificationEnsemble: m = margin (…, name, value)

Behaves as CompactClassificationEnsemble.margin and takes the same Name-Value arguments.

See also: ClassificationEnsemble, CompactClassificationEnsemble.margin

ClassificationEnsemble: imp = predictorImportance (obj)
ClassificationEnsemble: [imp, ma] = predictorImportance (obj)

Behaves as CompactClassificationEnsemble.predictorImportance.

See also: ClassificationEnsemble, CompactClassificationEnsemble.predictorImportance

ClassificationEnsemble: label = resubPredict (obj)
ClassificationEnsemble: [label, scores] = resubPredict (…)
ClassificationEnsemble: […] = resubPredict (…, name, value)

predict on X, taking the same Name-Value arguments.

See also: ClassificationEnsemble, ClassificationEnsemble.predict

ClassificationEnsemble: L = resubLoss (obj)
ClassificationEnsemble: L = resubLoss (…, name, value)

loss on X and Y, weighted by W unless 'Weights' are given.

See also: ClassificationEnsemble, ClassificationEnsemble.loss

ClassificationEnsemble: e = resubEdge (obj)
ClassificationEnsemble: e = resubEdge (…, name, value)

edge on X and Y, weighted by W unless 'Weights' are given.

See also: ClassificationEnsemble, ClassificationEnsemble.edge

ClassificationEnsemble: m = resubMargin (obj)
ClassificationEnsemble: m = resubMargin (…, name, value)

margin on X and Y, taking the same Name-Value arguments.

See also: ClassificationEnsemble, ClassificationEnsemble.margin