Упорядочите ансамбль сложенных в мешок деревьев.
Сгенерируйте выборочные данные.
Можно создать уволенный ансамбль классификации 300 деревьев от выборочных данных.
bag = fitrensemble(X,Y,'Method','Bag','NumLearningCycles',300);
fitrensemble
использует объект templateTree()
дерева шаблона по умолчанию
как слабый ученик, когда 'Method'
'Bag'
. В этом примере, для воспроизводимости, задают 'Reproducible',true
когда вы создаете древовидный объект шаблона, и затем используете объект в качестве слабого ученика.
Упорядочите ансамбль сложенных в мешок деревьев регрессии.
Starting lasso minimization for Lambda=0.001. Initial MSE=0.109923.
Lasso minimization completed pass 1 for Lambda=0.001
MSE = 0.086912
Relative change in MSE = 0.264768
Number of learners with non-zero weights = 15
Lasso minimization completed pass 2 for Lambda=0.001
MSE = 0.0670602
Relative change in MSE = 0.296029
Number of learners with non-zero weights = 34
Lasso minimization completed pass 3 for Lambda=0.001
MSE = 0.0623931
Relative change in MSE = 0.0748019
Number of learners with non-zero weights = 51
Lasso minimization completed pass 4 for Lambda=0.001
MSE = 0.0605444
Relative change in MSE = 0.0305348
Number of learners with non-zero weights = 70
Lasso minimization completed pass 5 for Lambda=0.001
MSE = 0.0599666
Relative change in MSE = 0.00963517
Number of learners with non-zero weights = 94
Lasso minimization completed pass 6 for Lambda=0.001
MSE = 0.0598835
Relative change in MSE = 0.00138719
Number of learners with non-zero weights = 105
Lasso minimization completed pass 7 for Lambda=0.001
MSE = 0.0598608
Relative change in MSE = 0.000379227
Number of learners with non-zero weights = 113
Lasso minimization completed pass 8 for Lambda=0.001
MSE = 0.0598586
Relative change in MSE = 3.72856e-05
Number of learners with non-zero weights = 115
Lasso minimization completed pass 9 for Lambda=0.001
MSE = 0.0598587
Relative change in MSE = 6.42954e-07
Number of learners with non-zero weights = 115
Lasso minimization completed pass 10 for Lambda=0.001
MSE = 0.0598587
Relative change in MSE = 4.53658e-08
Number of learners with non-zero weights = 115
Completed lasso minimization for Lambda=0.001.
Resubstitution MSE changed from 0.109923 to 0.0598587.
Number of learners reduced from 300 to 115.
Starting lasso minimization for Lambda=0.1. Initial MSE=0.109923.
Lasso minimization completed pass 1 for Lambda=0.1
MSE = 0.104917
Relative change in MSE = 0.0477191
Number of learners with non-zero weights = 12
Lasso minimization completed pass 2 for Lambda=0.1
MSE = 0.0851031
Relative change in MSE = 0.232821
Number of learners with non-zero weights = 30
Lasso minimization completed pass 3 for Lambda=0.1
MSE = 0.081245
Relative change in MSE = 0.0474877
Number of learners with non-zero weights = 40
Lasso minimization completed pass 4 for Lambda=0.1
MSE = 0.0796749
Relative change in MSE = 0.0197067
Number of learners with non-zero weights = 53
Lasso minimization completed pass 5 for Lambda=0.1
MSE = 0.0788411
Relative change in MSE = 0.0105746
Number of learners with non-zero weights = 64
Lasso minimization completed pass 6 for Lambda=0.1
MSE = 0.0784959
Relative change in MSE = 0.00439793
Number of learners with non-zero weights = 81
Lasso minimization completed pass 7 for Lambda=0.1
MSE = 0.0784429
Relative change in MSE = 0.000676468
Number of learners with non-zero weights = 88
Lasso minimization completed pass 8 for Lambda=0.1
MSE = 0.078447
Relative change in MSE = 5.24449e-05
Number of learners with non-zero weights = 88
Completed lasso minimization for Lambda=0.1.
Resubstitution MSE changed from 0.109923 to 0.078447.
Number of learners reduced from 300 to 88.
regularize
отчеты относительно его прогресса.
Смотрите получившуюся структуру регуляризации.
ans = struct with fields:
Method: 'Lasso'
TrainedWeights: [300x2 double]
Lambda: [1.0000e-03 0.1000]
ResubstitutionMSE: [0.0599 0.0784]
CombineWeights: @classreg.learning.combiner.WeightedSum
Проверяйте, у сколько учеников в упорядоченном ансамбле есть положительные веса. Это ученики, включенные в севший ансамбль.
Уменьшите ансамбль, использующий веса от Lambda = 0.1
.
cmp =
CompactRegressionEnsemble
ResponseName: 'Y'
CategoricalPredictors: []
ResponseTransform: 'none'
NumTrained: 88
Properties, Methods
Компактный ансамбль содержит 87
члены, меньше, чем 1/3 исходного 300
.