CompactRegressionEnsemble class

Compact regression ensemble class


Compact version of a regression ensemble (of class RegressionEnsemble). The compact version does not include the data for training the regression ensemble. Therefore, you cannot perform some tasks with a compact regression ensemble, such as cross validation. Use a compact regression ensemble for making predictions (regressions) of new data.


cens = compact(ens) constructs a compact decision ensemble from a full decision ensemble.

Input Arguments


A regression ensemble created by fitensemble.



List of categorical predictors. CategoricalPredictors is a numeric vector with indices from 1 to p, where p is the number of columns of X.


A string describing how the ensemble combines learner predictions.


Number of trained learners in the ensemble, a positive scalar.


A cell array of names for the predictor variables, in the order in which they appear in X.


A string with the name of the response variable Y.


Function handle for transforming scores, or string representing a built-in transformation function. 'none' means no transformation; equivalently, 'none' means @(x)x.

Add or change a ResponseTransform function using dot notation:

cens.ResponseTransform = @function


The trained learners, a cell array of compact regression models.


A numeric vector of weights the ensemble assigns to its learners. The ensemble computes predicted response by aggregating weighted predictions from its learners.


lossRegression error
predictPredict response of ensemble
predictorImportanceEstimates of predictor importance
removeLearnersRemove members of compact regression ensemble

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.


Construct a regression ensemble for the carsmall data. Make a compact version of the ensemble, and compare its size to that of the full ensemble:

load carsmall
learner = templateTree('MinParent',20);
ens = fitensemble([Weight, Cylinders],MPG,...
cens = compact(ens);
ee = whos('ens'); % ee.bytes = size of ensemble in bytes
cee = whos('cens');
[ee.bytes cee.bytes]

ans =
      606903      587096
Was this topic helpful?