フィルターのクリア

How to use Bayesian Optimization?

5 ビュー (過去 30 日間)
Amy Xu
Amy Xu 2017 年 4 月 19 日
コメント済み: Don Mathis 2017 年 4 月 27 日
I'm trying to run the following Mathworks example with my own X and Y:
"Tune Random Forest Using Quantile Error and Bayesian Optimization"
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?

回答 (1 件)

Don Mathis
Don Mathis 2017 年 4 月 20 日
You need to pass Y into oobErrRF. Change its first line to
function oobErr = oobErrRF(params,X,Y)
And change the call on line 66 of your main file to
results = bayesopt(@(params)oobErrRF_editted(params,X,Y),hyperparametersRF,...
That fixes your error. But after that you get a new error, because inside oobErrRF you're calling oobQuantileError on a classification random forest, while it's only defined for regression random forests. Are you trying to do classification or regression?
  2 件のコメント
Amy Xu
Amy Xu 2017 年 4 月 27 日
Thanks @Don.
In fact, I am trying to do classification. Can we use Bayesian Optimization for classification?
Don Mathis
Don Mathis 2017 年 4 月 27 日
Yes you can. I edited your code to call 'oobError' instead of 'oobQuantileError', and took the mean over all trees. I also told your final 'Mdl' to train with Method 'classification' and turned on 'OOBPredictions' so you can see the performance of the final model. I also told 'bayesopt' to use Verbose=1. I've attached the edited files.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by