Create a compact bag of trees for efficiently making predictions on new data.
Load theionosphere
data set.
Train a bag of 100 classification trees using all measurements and theAdaBoostM1
method.
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' Properties, Methods
Mdl
is aTreeBagger
model object that contains the training data, among other things.
Create a compact version ofMdl
.
CMdl = CompactTreeBagger Ensemble with 100 bagged decision trees: Method: classification NumPredictors: 34 ClassNames: 'b' 'g' Properties, Methods
CMdl
is aCompactTreeBagger
model object.CMdl
is almost the same asMdl
. One exception is that it does not store the training data.
Compare the amounts of space consumed byMdl
andCMdl
.
Mdl
consumes more space thanCMdl
.
CMdl.Trees
stores the trained classification trees (CompactClassificationTree
model objects) that composeMdl
.
显示一个图的第一棵树the compact model.
By default,TreeBagger
grows deep trees.
Predict the label of the mean ofX
using the compact ensemble.
predMeanX =1x1 cell array{'g'}