Compact ensemble of decision trees grown by bootstrap aggregation
CompactTreeBagger class is a lightweight
class that contains the trees grown using
CompactTreeBagger does not preserve any information
TreeBagger grew the decision trees. It
does not contain the input data used for growing trees, nor does it
contain training parameters such as minimal leaf size or number of
variables sampled for each decision split at random. You can only
CompactTreeBagger for predicting the response
of the trained ensemble given new data
X, and other
CompactTreeBagger lets you save the trained
ensemble to disk, or use it in any other way, while discarding training
data and various parameters of the training configuration irrelevant
for predicting response of the fully grown ensemble. This reduces
storage and memory requirements, especially for ensembles trained
on large data sets.
|CompactTreeBagger||Create CompactTreeBagger object|
a compact version of
CMdl = compact(
TreeBagger model object. You can predict
CMdl exactly as you can using
CMdl does not contain training data,
you cannot perform some actions, such as make out-of-bag predictions
|combine||Combine two ensembles|
|error||Error (misclassification probability or MSE)|
|mdsprox||Multidimensional scaling of proximity matrix|
|meanMargin||Mean classification margin|
|outlierMeasure||Outlier measure for data|
|predict||Predict responses using ensemble of bagged decision trees|
|proximity||Proximity matrix for data|
|setDefaultYfit||Set default value for |
For classification, you can set this property to either
For regression, you can set this property to any numeric scalar. The default is the mean of the response for the training data.
Create a compact bag of trees for efficiently making predictions on new data.
ionosphere data set.
Train a bag of 100 classification trees using all measurements and the
Mdl = TreeBagger(100,X,Y,'Method','classification')
Mdl = TreeBagger Ensemble with 100 bagged decision trees: Training X: [351x34] Training Y: [351x1] Method: classification NumPredictors: 34 NumPredictorsToSample: 6 MinLeafSize: 1 InBagFraction: 1 SampleWithReplacement: 1 ComputeOOBPrediction: 0 ComputeOOBPredictorImportance: 0 Proximity:  ClassNames: 'b' 'g'
Mdl is a
TreeBagger model object that contains the training data, among other things.
Create a compact version of
CMdl = compact(Mdl)
CMdl = CompactTreeBagger Ensemble with 100 bagged decision trees: Method: classification NumPredictors: 34 ClassNames: 'b' 'g'
CMdl is a
CompactTreeBagger model object.
CMdl is almost the same as
Mdl. One exception is that it does not store the training data.
Compare the amounts of space consumed by
mdlInfo = whos('Mdl'); cMdlInfo = whos('CMdl'); [mdlInfo.bytes cMdlInfo.bytes]
ans = 1971143 1829948
Mdl consumes more space than
CMdl.Trees stores the trained classification trees (
CompactClassificationTree model objects) that compose
Display a graph of the first tree in the compact model.
TreeBagger grows deep trees.
Predict the label of the mean of
X using the compact ensemble.
predMeanX = predict(CMdl,mean(X))
predMeanX = cell 'g'
Trees property of
a cell vector of
objects. For a textual or graphical display of tree
the cell vector, enter
Value. To learn how this affects your use of the class, see Comparing Handle and Value Classes in the MATLAB® Object-Oriented Programming documentation.