Bayesopt result is "No feasible points were found." in classifier optimization
2 views (last 30 days)
Show older comments
Hello everyone,
I need to tune a random forest in a classification task and I am following this guide from matlab documentation that does the same but for regression.
I modified the code to optimize a classifier, but I I'm struggling in understanding why bayesopt can't find any feasible point. This is an example of what I get:
|=====================================================================================================|
| Iter | Eval | Objective | Objective | BestSoFar | BestSoFar | minLS | numPTS |
| | result | | runtime | (observed) | (estim.) | | |
|=====================================================================================================|
| 1 | Error | NaN | 0.19415 | NaN | NaN | 20 | 3 |
| 2 | Error | NaN | 0.20093 | NaN | NaN | 2 | 1 |
| 3 | Error | NaN | 0.2076 | NaN | NaN | 2 | 4 |
| 4 | Error | NaN | 0.19925 | NaN | NaN | 17 | 6 |
| 5 | Error | NaN | 0.19505 | NaN | NaN | 13 | 2 |
__________________________________________________________
Optimization completed.
MaxObjectiveEvaluations of 5 reached.
Total function evaluations: 5
Total elapsed time: 1.7825 seconds.
Total objective function evaluation time: 0.99699
No feasible points were found.
I also add my code in case it could be helpful:
function bestHyperparameters = RF(trainingData,predictorNames)
rng('default'); % For reproducibility
% Extract predictors and response
inputTable = trainingData;
predictors = inputTable(:, predictorNames);
response = inputTable.Class;
% Set hyperparameters
maxMinLS = 20;
minLS = optimizableVariable('minLS',[1,maxMinLS],'Type','integer');
numPTS = optimizableVariable('numPTS',[1,size(predictors,2)-1],'Type','integer');
hyperparametersRF = [minLS; numPTS];
% obj. function
function oobErr = oobErrRFM(params,X,response)
randomForest = TreeBagger(30,X,response,'Method','classification',...
'OOBPrediction','on','MinLeafSize',params.minLS,...
'NumPredictorstoSample',params.numPTS);
oobErr = oobError(randomForest);
end
% Optimization
results = bayesopt(@(params)oobErrRFM(params,predictors,response),hyperparametersRF,...
'Verbose',1,'MaxObjectiveEvaluations',5);
bestOOBErr = results.MinObjective;
bestHyperparameters = results.XAtMinObjective;
end
I hope someone can help me! Thank you in advance,
Marta
1 Comment
Stephan
on 2 Feb 2019
remove your comment and make an answer to this question instead. then accept your answer. this way people know the issue is solved successfully.
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Classification Ensembles in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!