Code covered by the BSD License  

Highlights from
Multi Class Support Vector Machine

3.46154
3.5 | 14 ratings Rate this file 174 Downloads (last 30 days) File Size: 2.17 KB File ID: #33170 Version: 1.4
image thumbnail

Multi Class Support Vector Machine

by

Anand Mishra (view profile)

  • 1 file
  • 174 downloads
  • 3.46154

 

07 Oct 2011 (Updated )

This function removes out the limitation of MATLAB SVM function of two class and uses more classes.

| Watch this File

File Information
Description

This function can classify more than two classes which is limited in MATLAB SVM. This is primary work and does not include plotting function for SVM.
This is version 3.0 of original function which removes some limitations of first & Second one.

Acknowledgements

This file inspired Multi Class Svm.

Required Products Bioinformatics Toolbox
Statistics and Machine Learning Toolbox
MATLAB
MATLAB release MATLAB 7.12 (R2011a)
MATLAB Search Path
/
Other requirements Bioinformatics Toolbox only.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (43)
15 Jun 2015 saadoon al-sumaidaee

Hi all,
Just I need to know is the Train set dimension is considered or no?
i.e. I have a vector of features, each vector length has equal to 32256, and I have a six class. Can I use multi class in the classifying the facial expressions?

Comment only
30 May 2015 Tung Le  
30 Mar 2015 KALYAN KUMAR

what exactly group train is??
can i know train data and test data matrix sizes for example?

Comment only
20 Mar 2015 aarini

aarini (view profile)

How to plot the classified result? Kindly help.

Comment only
04 Mar 2015 Anand Mishra

Anand Mishra (view profile)

  • 1 file
  • 174 downloads
  • 3.46154

@kamil kamil, @ LEON, @chaou, @ Anirban, @ M@lik Ali, @ yavuzca23, @ Niyalatul, @ Mehrdad Azh, @ Subha, @ jamila, @ Aya, @ billel madridi, @ Weizhi Li, @ raha, @ mustafa alnasser, @ jie, @ shila, @ sunil ds, @ Roshni rahul
Sorry Everyone again, for late reply because of very busy schedule I am this much late to reply.
Not able to answer every query, I would suggest everyone to read answers given by many other members in Commenets to solve many your problems before asking.
I think many of you are not finding example of file in Preview Image above. For you I am giving 1 example given by user Cody.I appreciate Cody work.

%% SVM Multiclass Example
% SVM is inherently one vs one classification.
% This is an example of how to implement multiclassification using the
% one vs all approach.
T=[ 1 10;2 20;3 30;4 40;5 50;6 66;3 30;4.1 42];
test=[3 34; 1 14; 2.2 25; 6.2 63];
C=[1;1;2;2;3;3;2;2];
results = multisvm(T, C, test);
disp('multi class problem');
disp(results);

Thank You for taking help.

Comment only
05 Feb 2015 Roshni rahul

sir,im doing my thesis on facial expression recognition.i am using CK+ dataset.can use please tell me how to create training set,test set and group set as i want to classify expression into 6 classes ie anger,surprise,sad,disgust,happiness and Fear.

19 Jan 2015 sunil ds

sir, pl inform me how to find input values to the training set, test test and group test?

Comment only
15 Jan 2015 sunil ds

sir, i'm new to matlab. how to find values to give test set and training set.

Comment only
04 Nov 2014 shila

shila (view profile)

Hello sir. i have used this function. i have to classify 3 classes. but its not getting expected result.. its shows only one class its unable to group rest two classes.. whts the problme?

Comment only
27 Oct 2014 jie

jie (view profile)

Could you please tell me the reference of your aglorithm? Thanks a lot.

24 Sep 2014 mustafa alnasser

I am using neural network for classification of four classes and I am trying to use SVM to do the same analysis but I do not how to reflect 4 input vectors on the three sets (group, test.)

Comment only
28 May 2014 Ansuman Mahapatra  
16 Jan 2014 raha

raha (view profile)

hi
i am new in svm
i wonder how calculate accuracy in this algorithm
plz help me

Comment only
01 Oct 2013 Weizhi Li

Error using seqminopt>seqminoptImpl (line 198)
No convergence achieved within maximum number of iterations.

Error in seqminopt (line 81)
[alphas offset] = seqminoptImpl(data, targetLabels, ...

Error in svmtrain (line 499)
[alpha, bias] = seqminopt(training, groupIndex, ...

Error in multisvm (line 20)
models(k) = svmtrain(TrainingSet,G1vAll);

I think it does not work

12 May 2013 billel madridi

hey ; why i can't see the file could you send it to me to( billelnet009@gmail.com )
please i really need it it's emergency

24 Apr 2013 Aya

Aya (view profile)

please i need to know it's one vs all or one vs one relation??

Comment only
13 Apr 2013 jamila

jamila (view profile)

Hi
thank you for this code, it great ; but i have an error when i try to change the kernel function. The error is " Error using ==> seqminopt>seqminoptImpl at 203
No convergence achieved within maximum number of iterations.

Error in ==> seqminopt at 84
[alphas offset] = seqminoptImpl(data, targetLabels, ...

Error in ==> svmtrain at 541
[alpha bias] = seqminopt(training, groupIndex, ...

Error in ==> multisvm at 49
svmStruct = svmtrain(T,newClass,'kernel_function','linear' ); %
I am using rbf kernel function, you must change it also

Error in ==> teststa at 61
[itrfin] = multisvm( data,classa,test )"

can you help me please?

Comment only
06 Feb 2013 Subha

Subha (view profile)

sir,
is it possible to plot confusion matrix for this program... if so how to do tat.. we have tried many combinations but does not working...
....
else any method to calculate the performance of the overall system from test data's..

Comment only
11 Jan 2013 Mehrdad Azh

Hi

Could you please upload a test case for us to see how to use it?

Thnx.

11 Jan 2013 Mehrdad Azh

Hi

Could you please upload a test case for us to see how to use it?

Thnx.

Comment only
21 Dec 2012 Niyalatul

Hi,
I'm still new to learn this topic.
How can I learn multiclass svm more specific (literature suggestions that I can use, like the books and other)?

Thanks

Comment only
08 Dec 2012 Cody

Cody (view profile)

  • 1 file
  • 309 downloads
  • 3.92857

Please see my revision of this code here:
http://www.mathworks.com/matlabcentral/fileexchange/39352

Comment only
07 Dec 2012 Cody

Cody (view profile)

  • 1 file
  • 309 downloads
  • 3.92857

Hello, thanks for your contribution. It helped me out, but it was confusing and I have re-written and uploaded a clearer function that does the same thing. It is only about 15 lines of code. I'll provide a link when it is approved.

07 Dec 2012 Cody

Cody (view profile)

  • 1 file
  • 309 downloads
  • 3.92857
 
08 Nov 2012 yavuzca23

Hi,
does this code work with 6 inputs which include 3200 samples , and 30 classes(outputs)?

Comment only
14 Aug 2012 M@lik Ali

Can any one tel me how i can run this program, please i am new in mat-lab.
what and how to give input to the function,
i have a feature vector of the images how i can use it.

Comment only
13 Jul 2012 Anirban

Hey Anand

Thank for sharing 'multisvm' code, its really useful! But can you tell is there any way to get the learned models so that while testing for next time I dot need to train again. Because training in every test step is pretty time consuming.

Thanks in advance for your suggestion

Comment only
26 Jun 2012 MML

MML (view profile)

thanks a lot Anand for sharing your code.
I found it very useful.

@Chaou and @Yap
The class-vector (C) should be a row vector. I had the same problem when I tried to use a column vector for C. I hope this resolves the problem.

29 May 2012 Yap

Yap (view profile)

me too, my result output all 1 1 1 1.....I hope some1 could help!

27 May 2012 Chaou

Chaou (view profile)

Hello, I'd like first to thank you for this program. But unfortunately, it doesn't work in my case.
I'm obtaining a itrfin=1 in all cases. I'm using a test vector of 30 elements, and I obtain a itrfin vector = 1 1 1 1.... 1.

Why ? I really appreciate your help. Thanks !

20 Apr 2012 Shikha

Shikha (view profile)

 
12 Apr 2012 LEONG

LEONG (view profile)

Hello,
I am searching a way of plotting the multi-svm.

Description about my project:
My application is actually is to classify 4 four classes of different input signals. i have three trial for each subject which each of them need to four different of movement..

Here is my some questions:

1. Does multi-svm that Anand provided able to plot the graph?
2. If yes, how to plot it ..i mean the algorithm..
3. beside, i want to know whether the multi-svm support for classperf ? because i test it before.. it come out with error as:

??? Error using ==> classperf at
270
The classifier output CLASSOUT
does not have the same size
as the ground truth and there was
not any TESTIDX provided.

Error in ==>
multisvm_classification2 at 63
classperf(cp,classes);

4. What does that mean..i got find the error at internet but the the problem still did'nt solve..
any solution for it ?

5. Can i use more than two training data but with one test in multi-svm version 2.0 or 3.0 ?can i use it to obtain classperformance of multi-training and test for many data?

Your suggestion will be appreciated..
thank you

Comment only
05 Apr 2012 kamil kamil

Hello,
Thank you for this program.
How we can determine the best (Sigma, C) with this method ?

Comment only
04 Apr 2012 Anand Mishra

Anand Mishra (view profile)

  • 1 file
  • 174 downloads
  • 3.46154

Download Version 3.0 of this function and give suggestions for improving it. Version 3.0 includes the usage of multiple row testing matrix input.

Comment only
04 Apr 2012 Anand Mishra

Anand Mishra (view profile)

  • 1 file
  • 174 downloads
  • 3.46154

@pallavi
Sorry for late reply, but I was little bit busy.
You can use '|' instead of '||' or '&' instead of '&&' in function,hope this will work for your application. You can refer Operators and Flow Control in Matlab for more information.
Thank You for taking help.

Comment only
04 Apr 2012 Anand Mishra

Anand Mishra (view profile)

  • 1 file
  • 174 downloads
  • 3.46154

@Gomathi C,
Sorry for late reply, but I was little bit busy.
By the way you don't have to worry about using this function for two class SVM. You can not use this function for two classes, because their is an inbuilt MATLAB function for two classes classification present in MATLAB IDE. I created this function to extend the facilities of inbuilt MATLAB function.
I am not able to understand your output of GLCM but you can look image associated with my file in MATLAB file exchange for example of using my SVM function.
If you still find any problem in using your inputs for your program then please clarify me whole parameters you are using for GLCM like autoc, contr etc. So that I am able to tell you more clearly.
Hope this will help you.
Thanks for using my function.

Comment only
22 Mar 2012 Gomathi C

I actually obtained the texture features using GLCM. My output for that was

stats =

autoc: [1.857855266614132e+000 1.857955341199538e+000]
contr: [5.103143332457753e-002 5.030548650257343e-002]
corrm: [9.512661919561399e-001 9.519459060378332e-001]
corrp: [9.512661919561385e-001 9.519459060378338e-001]
cprom: [7.885631654779597e+001 7.905268525471267e+001]

Now how should I give this as an input to the SVM program. Kindly guide me.

Comment only
16 Feb 2012 pallavi

when I run the program , I fet an error:
??? Operands to the || and && operators must be convertible to logical scalar values.
how to solve it?

Comment only
14 Oct 2011 Anand Mishra

Anand Mishra (view profile)

  • 1 file
  • 174 downloads
  • 3.46154

@guo,
Hi, you correctly spotted the algorithm behind this file.
Now take an example,
Suppose
T=[1 2 3 4;2 3 4 5;3 4 5 6;4 5 6 7]
C=[1 2 3 4]
tst=[3 4 5 6]
then run the function and then debug it step by step to understand algorithm.
It becomes clearer how the class is calculated.
Thanks for your interest.

Comment only
13 Oct 2011 guo

guo (view profile)

Hi again. I wonder how you solve an multi-class problem. It is likely that you decompose an M-class problem into a series of two-class problems using one-against-all implementation, right?

Comment only
13 Oct 2011 guo

guo (view profile)

Helloļ¼Could you please give a detailed example for input parameter specification?

11 Oct 2011 Anand Mishra

Anand Mishra (view profile)

  • 1 file
  • 174 downloads
  • 3.46154

@Aziz,
Dear Aziz, svmclassify never makes 'classes' variable as a row vector of 0 and 1. The 'classes' can used only for checking loop condition i.e.,whether loop is to be terminate or not (check in while condition).
Variables 'newClass' and 'c1' can takes form of vector(0 and 1) and changing their sizes in each iteration.

I am using operands || and && because I am working on C Programming also so I am habitual of using this instead of logical scalar values.

May this solve out your confusions. Read Comments on file thoroughly. Thanks for taking help.
Regards...Anand Mishra.

Comment only
10 Oct 2011 Aziz

Aziz (view profile)

This is great but I wonder what purpose the 'classes' variable serve? At first it looks like an indicator to keep looping if the 'classes' variable still not equal 1 (line 32, line 65-67) but then you use it as result from svmclassify (line 39), which will make it a row vector of 0 and 1. Hence it couldn't be used in loop indicators. It would make this appear

??? Operands to the || and && operators must be convertible to logical scalar values.

Am I missing something?

Comment only
Updates
14 Oct 2011 1.1

This is Version 2.0 of Original Function.

04 Apr 2012 1.2

This is the update version 3.0 of original created Multi-Class SVM function by me.

04 Apr 2012 1.3

This is version 3.0 of original function.

04 Mar 2015 1.4

Now the function is available in toolbox also.

Contact us