please help me to classify data in three group using 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

 採用された回答

the cyclist
the cyclist 2013 年 7 月 28 日
編集済み: the cyclist 2013 年 7 月 28 日

0 投票

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 件のコメント

mahendra
mahendra 2013 年 7 月 29 日
sir please guide me to classify data in 3 group and other changes in code according to it. Thank u
load fisheriris
data = [meas(:,1), meas(:,2)];
groups = ismember(species,'setosa');
Instead of two group, classify data in three group --sentosa,versicolor,virginica-- what is other change in code
[train, test] = crossvalind('holdOut',groups);
svmStruct = svmtrain(data(train,:),groups(train),'showplot',true);
classes = svmclassify(svmStruct,data(test,:),'showplot',true);
classperf(cp,classes,test); cp.CorrectRate
the cyclist
the cyclist 2013 年 7 月 29 日
May I suggest that you start a new question for this, with a little bit more detail on what you are trying to do? That way, more people will see it, and you might have a better chance of getting an answer that helps you.
the cyclist
the cyclist 2013 年 7 月 29 日
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.
mahendra
mahendra 2013 年 7 月 30 日
thanks for advice...sir

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 7 月 29 日

0 投票

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 件のコメント

the cyclist
the cyclist 2013 年 7 月 29 日
@mahendra:
You might also want to consider k-means clustering for this.
doc kmeans
for details.
mahendra
mahendra 2013 年 7 月 30 日
Thanks for idea SIr. But Problem is how to implement in matlab code _ Distinguishing fisheriris data in sentosa,versicolor,virginica .
Walter Roberson
Walter Roberson 2013 年 7 月 30 日
In the first pass, temporarily renumber all samples in class #2 and #3 to be numbered #4, leaving class #1 as class #1. Train on that and save the resulting classifier ('A').
In the second pass, remove all samples in class #1, and train #2 vs #3, and save the resulting classifier ('B')
Now, to use this, classify the unlabeled samples using classifier A. The samples will get classified as being in class #1 or in #4. Extract the ones classified #1: those belong to class #1.
Take everything that was left (#4), remove the #4 label, and classify the (now unlabeled) samples using classifier B. The samples will get classified as being in class #2 or in #3.
Now, each sample was classified as #1 by running the first classifier, or was classified as #2 or #3 using the second classifier. The task is finished.
mahendra
mahendra 2013 年 7 月 30 日
Thanks Sir,it is more clear idea for me.But problem is that i am too much new for MATLAB programming ,still with this hint also (you provided) i am unable to build code.
please help me for code with fisheriris classification in three group,with ur code i try to understand way to program(coding) ,so that i can try on large data.
with your code i try to understand how to implement your concept in form of coding(programming)in matlab.
THANKS U SIR.
Walter Roberson
Walter Roberson 2013 年 7 月 30 日
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
Tommy Carpenter 2015 年 3 月 19 日
This is not the recommended way to perform multi class SVM. See: http://stats.stackexchange.com/questions/21465/best-way-to-perform-multiclass-svm

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by