Main Content

removeLearners

Remove members of compact classification ensemble

Description

cens1 = removeLearners(cens,idx) creates a compact classification ensemble identical to cens excluding the ensemble members in the idx vector.

example

Examples

collapse all

Create a compact classification ensemble. Compact it further by removing members of the ensemble.

Load the ionosphere data set.

load ionosphere

Train a classification ensemble for the ionosphere data using AdaBoostM1. Specify tree stumps as the weak learners.

t = templateTree(MaxNumSplits=1);
ens = fitcensemble(X,Y,Method="AdaBoostM1",Learners=t);

Create a compact classification ensemble cens from ens.

cens = compact(ens);

Remove the last 50 members of the ensemble.

idx = cens.NumTrained-49:cens.NumTrained;
cens1 = removeLearners(cens,idx);

Input Arguments

collapse all

Compact classification ensemble model object, specified as a CompactClassificationEnsemble model object created with compact.

Indices of learners to remove, specified as a vector of positive integers with entries in the range 1 to cens.NumTrained, where cens.NumTrained is the number of members in cens. cens1 contains all members of cens except those with indices in idx.

Typically, you set idx = j:cens.NumTrained for some positive integer j.

Example: idx=[3:5]

Data Types: single | double

Tips

  • Removing learners reduces the memory used by the ensemble and speeds up its predictions.

  • To retain only one ensemble, set cens1 equal to cens.

Extended Capabilities

Version History

Introduced in R2011a