MATLAB: Please help me to classify data in three group using SVM .

svm

load fisheriris
data = [meas(:,1), meas(:,2)];
groups = ismember(species,'setosa');
% create a new column vector,
% groups, to classify data into two groups: Setosa and non-Setosa.
*_Instead of two group, classify data in three group --sentosa,versicolor,virginica-- what is other change in code_*
[train, test] = crossvalind('holdOut',groups);
cp = classperf(groups);
classperf(cp,classes,test);
cp.CorrectRate
svmStruct = svmtrain(data(train,:),groups(train),...
'showplot',true,'boxconstraint',1e6);
classes = svmclassify(svmStruct,data(test,:),'showplot',true);
classperf(cp,classes,test);
cp.CorrectRate
ThANks u

Best Answer

Here's one way:
[~,groupIdx] = ismember(species,{'setosa','versicolor','virginica'})
A more general way to do this would be
[~,groupIdx] = ismember(species,unique(species))
Related Question