please help me to classify data in three group using SVM .
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
mahendra
le 28 Juil 2013
Commenté : Tommy Carpenter
le 19 Mar 2015
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
0 commentaires
Réponse acceptée
the cyclist
le 28 Juil 2013
Modifié(e) : the cyclist
le 28 Juil 2013
Here's one way:
[~,groupIdx] = ismember(species,{'setosa','versicolor','virginica'})
A more general way to do this would be
[~,groupIdx] = ismember(species,unique(species))
4 commentaires
the cyclist
le 29 Juil 2013
For the sake of any future readers looking at this question/answer:
The question was substantially expanded after my answer was written (and accepted). It does not really answer this question well anymore.
Plus de réponses (1)
Walter Roberson
le 29 Juil 2013
To classify into three groups with SVM you need to use two steps for the classification. You first classify the first group vs (the second group together with the third group). You remove the elements that were classified as being in the first group, leaving (second group together with third group). You then classify the second group compared to that; after removing the elements identified as the second group, what is left over will be the third group.
6 commentaires
Walter Roberson
le 30 Juil 2013
You managed to create the code to get as far as classifying two classes; just use the same kinds of calls to create a second classifier and to classify using it.
Tommy Carpenter
le 19 Mar 2015
This is not the recommended way to perform multi class SVM. See: http://stats.stackexchange.com/questions/21465/best-way-to-perform-multiclass-svm
Voir également
Catégories
En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!