Documentation Center

  • Trial Software
  • Product Updates


Class: RegressionEnsemble

Prune ensemble


cmp = shrink(ens)
cmp = shrink(ens,Name,Value)


cmp = shrink(ens) returns a compact shrunken version of ens, a regularized ensemble. cmp retains only learners with weights above a threshold.

cmp = shrink(ens,Name,Value) returns an ensemble with additional options specified by one or more Name,Value pair arguments. You can specify several name-value pair arguments in any order as Name1,Value1,…,NameN,ValueN.

Input Arguments


A regression ensemble created with fitensemble.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.


Vector of nonnegative regularization parameter values for lasso. If ens.Regularization is nonempty (populate it with regularize), shrink regularizes ens using lambda. If ens contains a Regularization structure, you cannot pass lambda.

Default: []


Lower cutoff on weights for weak learners, a numeric nonnegative scalar. shrink creates cmp from those learners with weights above threshold.

Default: 0


Column index of ens.Regularization.TrainedWeights, a positive integer. shrink creates cmp with learner weights from this column.

Default: 1

Output Arguments


A regression ensemble of class CompactRegressionEnsemble. Use cmp for making predictions exactly as you use ens, with the predict method.

shrink orders the members of cmp from largest to smallest.


Shrink a 300-member bagged regression ensemble using 0.1 for the parameter lambda, and view the number of members of the resulting ensemble:

X = rand(2000,20);
Y = repmat(-1,2000,1);
Y(sum(X(:,1:5),2)>2.5) = 1;
bag = fitensemble(X,Y,'Bag',300,'Tree','type','regression');
cmp = shrink(bag,'lambda',0.1);

ans =

See Also

| |


Was this topic helpful?