simple example for SVM
显示 更早的评论
Can anyone give me an example of how I can start with support vector machine in MATLAB?
采纳的回答
更多回答(1 个)
Nirmal
2012-6-4
0 个投票
A simple example of multiclass SVM.
12 个评论
Walter Roberson
2012-6-4
Nirmal, in your example, your line
if Group(i,1)==1
should probably be
if Group1(i,1)==1
otherwise you are testing Group(i,1) which you set to all 0 just a few lines above.
Nirmal
2012-6-5
GroupF=zeros(90,1);
I am setting GroupF to zero not Group. (I know, my naming convention is not the greatest) but it does work.
Walter Roberson
2012-6-5
You are right, I did misread the code.
Ilya
2012-6-5
There seems to be an error in your code.
if Group1(i,1)==2
GroupF(i,1)=2;
else
GroupF(i,1)=3;
end
should be
if Group1(i,1)==1
GroupF(i,1)=2;
else
GroupF(i,1)=3;
end
Even if there is no error, there is a problem with this approach. You treat the classes asymmetrically. You separate 1 from 2 and 3 and then separate 3 from 1 and 2. Then you assign a new observation to class 2 if it is neither class 1 nor class 3. There are two problems here:
1. The lack of symmetry implies that the classification scheme is sensitive to the order of the classes. In your case, class 2 can work as a sink for all observations that are neither clearly class 1 nor class 3.
2. It is not clear how this extends to more than 3 classes.
Nirmal
2012-6-5
1. IRIS dataset has only three classes, so I dont see problem with the code with class 2 acting as a sink. ( I am not sure why I need to be worried about the symmetry though.)
2. If I need to extend it to lets say 4 classes, I need to separate first 1 then 2 followed by 3 and finally 4. It would require me to use SVM 3 times. Again I could also do it by starting with 4,3,2 and finally 1 acting as a sink. It just the matter of separating 2 classes each time, where one of the class is the class we are trying to separate and another classes contains the rest of it. (Is that not right?)
Ilya
2012-6-5
In this scheme, you can end up assigning all uncertain observations to the sink class. The confusion matrix can be heavily skewed in favor of that class. The choice of the sink class is determined by an arbitrary order of the classes in the data (because there is no symmetry). I would be reluctant to use any classifier in which one class gets a heavy load of predictions for no reason other than being arbitrarily chosen as a sink. It is a problem no matter how many classes you have - 3, 4 etc.
Nirmal
2012-6-5
I understand what you are saying but there is no uncertain items in IRIS data set. Out of 150 Items, 1-50 are setosa, 51-100 are versicolor and 101-150 are virginica.
Ilya
2012-6-5
Fisher iris is one of the easiest datasets around. Pretty much any classifier can separate the groups. It would be easy to come up with a multiclass example in which your scheme fails miserably but a standard approach such as, for instance, one-vs-one succeeds.
Mythili Sukumaran
2012-11-28
Nirmal,thanks for the code.
Walter Roberson
2015-11-30
LOKESH, which MATLAB version are you using, and where is your svm from? (There are few different SVM around.)
REMYA K
2020-11-17
This site is not available..what to do
类别
在 帮助中心 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!