Main Content

compact

Reduce size of regression ensemble model

Description

cens = compact(ens) returns a CompactRegressionEnsemble version of the trained regression ensemble model ens.

You can predict regressions using the CompactRegressionEnsemble object cens in the same way as when you use ens. However, because cens does not contain training data, you cannot perform some actions, such as cross-validation.

example

Examples

collapse all

Compare the size of a regression ensemble for the carsmall data to the size of the compact version of the ensemble.

Load the carsmall data set and select acceleration, number of cylinders, displacement, horsepower, and vehicle weight as predictors.

load carsmall
X = [Acceleration Cylinders Displacement Horsepower Weight];

Train an ensemble of regression trees.

ens = fitrensemble(X,MPG);

Create a compact version of ens and compare ensemble sizes.

cens = compact(ens);
b = whos("ens"); 
c = whos("cens");  
[b.bytes c.bytes]  % b.bytes = size of ens and c.bytes = size of cens
ans = 1×2

      474419      441262

The compact ensemble uses less memory.

Input Arguments

collapse all

Full regression ensemble model, specified as a RegressionEnsemble or RegressionBaggedEnsemble model object trained with fitrensemble.

Extended Capabilities

Version History

Introduced in R2011a