Esta página aún no se ha traducido para esta versión. Puede ver la versión más reciente de esta página en inglés.

shrink

Sintaxis

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

Description

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.

Argumentos de entrada

ens

A regression ensemble created with fitrensemble.

Argumentos de par nombre-valor

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

'lambda'

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.

Predeterminado: []

'threshold'

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

Predeterminado: 0

'weightcolumn'

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

Predeterminado: 1

Output Arguments

cmp

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.

Ejemplos

expandir todo

Shrink a 300-member bagged regression ensemble, and view the number of members of the resulting ensemble.

Generate sample data.

rng(10,'twister') % For reproducibility
X = rand(2000,20);
Y = repmat(-1,2000,1);
Y(sum(X(:,1:5),2)>2.5) = 1;

Shrink a 300-member bagged regression ensemble using 0.1 for the parameter lambda.

bag = fitrensemble(X,Y,'Method','Bag','NumLearningCycles',300,'Learners','Tree');
cmp = shrink(bag,'lambda',0.1);

View the number of members of the resulting ensemble.

cmp.NumTrained
ans = 87