www.gusucode.com > stats 源码程序 matlab案例代码 > stats/OptimizeAClassificationTreeExample.m

    %% Optimize Classification Tree
% This example shows how to optimize hyperparameters automatically using
% |fitctree|. The example uses Fisher's iris data.
%%
% Load Fisher's iris data.
load fisheriris
%%
% Optimize the cross-validation loss of the classifier, using the data in
% |meas| to predict the response in |species|.
X = meas;
Y = species;
Mdl = fitctree(X,Y,'OptimizeHyperparameters','auto')