how to define 'Y' in fitensemble function (Matlab 2011a)

1 次查看(过去 30 天)
how we can write Y (parameter of fitensemble function in Matlab 2011a)...
ens = fitensemble(X,Y,'AdaBoostM1',50,'tree');
I have tried to define it buit prompt the error as:
??? Error using ==> ClassLabel>ClassLabel.ClassLabel at 28 You must pass class labels as a vector.
Error in ==> FullClassificationModel>FullClassificationModel.prepareData at 133 allClassNames = levels(classreg.learning.internal.ClassLabel(Y));
Error in ==> FitTemplate>FitTemplate.fit at 167 [X,Y,dataPrepOut{1:this.NDataPrepOut}] = ...
Error in ==> fitensemble at 274 obj = fit(temp,X,Y);
Error in ==> ada_boost_ex1 at 12 ens1 = fitensemble(data,y,'AdaBoostM1',50,'tree');

回答(1 个)

Wayne King
Wayne King 2012-5-22
If you are doing classification as you are with 'AdaBoostM', then Y should be a categorical variable, character array, or cell array of strings.
So say you have two classes, sick and healthy. Your Y might look like this for 10 measurements.
Y = {'S','S','H','S','H','H','H','S','H','S'};
or
Y = nominal({'S','S','H','S','H','H','H','S','H','S'});

类别

Help CenterFile Exchange 中查找有关 Classification Ensembles 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by