Random forest slow optimization

조회 수: 2 (최근 30일)
Esmeralda Ruiz Pujadas
Esmeralda Ruiz Pujadas 2023년 3월 8일
답변: Amal Raj 2023년 3월 14일
Hello,
I am using ranfom forest with greedy optimization and it goes very slow. I don´t want to use the bayesian optimization. I wonder if I can specify the range to check.
Thank you
s = RandStream('mlfg6331_64');
reset(s);
options = statset("UseParallel",true,"UseSubstreams",true,"Streams",s);
myopts = struct('Optimizer','gridsearch','AcquisitionFunctionName','expected-
improvement-plus', 'ShowPlots',false); %'UseParallel',true,
classificationML = fitcensemble(...
predictors, ...
response, ...
'Method', 'Bag', ...
'NumLearningCycles', 100, ...
'Learners', template, ...
'ClassNames', [1; 2],'OptimizeHyperparameters',
{'MaxNumSplits','MinLeafSize'},'HyperparameterOptimizationOptions',
myopts,'Options',options);

채택된 답변

Amal Raj
Amal Raj 2023년 3월 14일
Hi,
s = RandStream('mlfg6331_64');
reset(s);
options = statset("UseParallel",true,"UseSubstreams",true,"Streams",s);
myopts = struct('Optimizer','gridsearch','AcquisitionFunctionName','expected-improvement-plus',...
'ShowPlots',false,...
'SearchRange',struct('MaxNumSplits',[1,10],'MinLeafSize',[1,5]));
classificationML = fitcensemble(...
predictors, ...
response, ...
'Method', 'Bag', ...
'NumLearningCycles', 100, ...
'Learners', template, ...
'ClassNames', [1; 2],...
'OptimizeHyperparameters',{'MaxNumSplits','MinLeafSize'},...
'HyperparameterOptimizationOptions',myopts,...
'Options',options);
The SearchRange field specifies a structure with fields for each hyperparameter you want to search. The values of these fields are two-element vectors indicating the minimum and maximum values to search. In this example, the search range for MaxNumSplits is from 1 to 10, and the search range for MinLeafSize is from 1 to 5.
By specifying the search range, you can limit the set of hyperparameters to be searched, which can speed up the optimization process. However, be aware that if the optimal hyperparameters lie outside the specified range, you may not find the best model.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by