www.gusucode.com > stats 源码程序 matlab案例代码 > stats/OptimizeARegressionEnsembleExample.m
%% Optimize Regression Ensemble % This example shows how to optimize hyperparameters automatically using % |fitrensemble|. The example uses the |carsmall| data. %% % Load the data. load carsmall %% % Find hyperparameters that minimize five-fold cross-validation loss by % using automatic hyperparameter optimization. % % For reproducibility, set the random seed and use the % |'expected-improvement-plus'| acquisition function. rng(1) Mdl = fitrensemble([Horsepower,Weight],MPG,'OptimizeHyperparameters','auto',... 'HyperparameterOptimizationOptions',struct('AcquisitionFunctionName',... 'expected-improvement-plus')) %% % The optimization searched over the methods for regression (|Bag| and % |LSBoost|), over |NumLearningCycles|, over the |LearnRate| for |LSBoost|, % and over the tree learner |MinLeafSize|. The output is the ensemble % regression with the minimum estimated cross-validation loss.