Remove members of compact regression ensemble
idx — Learner indices
vector of positive integers
Indices of learners to remove, specified as a vector of positive integers with entries
in the range
cens.NumTrained is the number of members in
cens1 contains all members of
cens except those with indices in
Typically, you set
idx = j:cens.NumTrained for some
Remove Learners from an Ensemble
Create a compact regression ensemble. Compact it further by removing members of the ensemble.
carsmall data set and select
Cylinders as predictors.
load carsmall X = [Weight Cylinders];
Train a regression ensemble using LSBoost. Specify tree stumps as the weak learners.
t = templateTree(MaxNumSplits=1); ens = fitrensemble(X,MPG,Method="LSBoost",Learners=t,... CategoricalPredictors=2);
Create a compact classification ensemble
cens = compact(ens);
Remove the last 50 members of the ensemble.
idx = cens.NumTrained-49:cens.NumTrained; cens1 = removeLearners(cens,idx);
Removing learners reduces the memory used by the ensemble and speeds up its predictions.
To retain just one ensemble, set
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Introduced in R2011a