How to get optimal tree when using random forest method

9 vues (au cours des 30 derniers jours)
Mekala balaji
Mekala balaji le 27 Déc 2016
Hi,
I use the
meas=[...
[53.4
194.5
220.5
273.1
312.3
331.7
159.7
199.5
293.9
390.7
392.1
398.9
399.1
400.3
52.1
249.3
357.7
44.8
163.9
200.5
335.1
92.4
130.3
77.1]]
species=[{'v16'
'v6'
'v1'
'v126'
'v6'
'v1'
'v16'
'v6'
'v5'
'v156'
'v6'
'v1'
'v16'
'v6'
'v12456'
'v56'
'v256'
'v2456'
'v6'
'v16'
'v1234'
'v16'
'v12356'
'v6'}]
I use below code:
b = TreeBagger(50,meas,species,'oobpred','on')
But how to get optimal tree? Many thanks in advance.

Réponses (2)

mizuki
mizuki le 30 Déc 2016
Optimize tree with Bayesian Optimization (use bayesopt function). This feature is introduced in R2016b.
  • Tune Random Forest Using Quantile Error and Bayesian Optimization
Also you can search optimal parameters with other methods such as gridsearch, but you need to write code. For gridsearch, this might help you:
  • How to do grid Search to optimize sigma using Matlab?
  2 commentaires
Amy Xu
Amy Xu le 19 Avr 2017
I'm trying to run the following Mathworks example with my own X and Y:
"Tune Random Forest Using Quantile Error and Bayesian Optimization"
https://jp.mathworks.com/help/stats/tune-random-forest-using-quantile-error-and-bayesian-optimization.html
But, I'm getting the following error:
Undefined function or variable 'Y'.
I have attached the modified code (place both files in one folder on your PC drive). Can anyone help?
Marta Caneda Portela
Marta Caneda Portela le 6 Sep 2022
What if I also need 5-fold cross-validation? I can't find any examples online

Connectez-vous pour commenter.


Don Mathis
Don Mathis le 20 Avr 2017
You could also try to find the best ensemble like this:
fitcensemble(meas,species,'OptimizeHyperparameters','all')
This will also try boosted decision trees in addition to random forests.

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by