How to retrieve optimal MinLeafSize after automatic hyperparameter optimization for Tree Ensemble (fitrensemble)?

조회 수: 12 (최근 30일)
Hi. I am running MATLAB's automatic Bayesian optimization for a number of parameters for a Tree Ensemble.
opts = struct('Kfold',4,'Optimizer','bayesopt');
Mdl = fitrensemble(X,Y,'OptimizeHyperparameters',{'Method','NumLearningCycles','LearnRate','MinLeafSize'},'HyperparameterOptimizationOptions',opts);
I understand that all the optimal parameters are embedded in the resulted object ‘Mdl’, but I was wondering if it’s possible to retrieve and save in a variable the optimal MinLeafSize. Even though I have found the rest optimized parameters:
Mdl.ModelParameters.Method %Method
Mdl.ModelParameters.NLearn %NumLearningCycles
Mdl.ModelParameters.LearnRate %LearnRate
but, I cannot obtain the MinLeafSize. However, I can see that it is listed among the properties of 'Mdl' under MinLeaf:
Mdl.ModelParameters.LearnerTemplates{1,1}
Anyone knows how to extract this? Thanks.

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 2월 6일
편집: Cris LaPierre 2021년 2월 6일
I ran both a tree and ensemble models optimizing minLeafSize. For a decision tree, MinLeaf is a model parameter, but not for an ensemble. The only way I could find to see the value was by viewing the template.
Mdl.ModelParameters.LearnerTemplates{1,1}
ans =
Fit template for regression Tree.
SplitCriterion: []
MinParent: []
MinLeaf: 126
MaxSplits: 10
NVarToSample: []
MergeLeaves: 'off'
Prune: 'off'
PruneCriterion: []
QEToler: []
NSurrogate: []
MaxCat: []
AlgCat: []
PredictorSelection: []
UseChisqTest: []
Stream: []
Reproducible: []
Version: 2
Method: 'Tree'
Type: 'regression'
  댓글 수: 3
Bernhard Suhm
Bernhard Suhm 2021년 2월 8일
You can use bestPoint(Mdl.HyperparameterOptimizationResults) to access the hyperparameters of the "best estimated" model, including 'MinLeafSize'
Haris K.
Haris K. 2021년 2월 9일
편집: Haris K. 2021년 2월 9일
Perfect! Exactly what I was looking. It might be worth adding this somewhere in the examples or in the inputs section of fitrtree(), fitrensemble() etc online documentation. Currently it is mentioned nowhere. Thank you both for your help!
(Bernhard, I am not sure if I can 'accept' your answer as THE answer, as it is a comment in Cris' answer. If you could please write it below, so that I can flag your answer as the accepted one..)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Regression Tree Ensembles에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by