How to train SVM having more than two groups?

9 views (last 30 days)
Minu
Minu on 16 May 2013
Answered: Dima Lisin on 15 Feb 2015
I want to train svm for ocr.When using svm got the message "SVMTRAIN only supports classification into two groups. GROUP contains 79 groups.". So how to train svm having more than two groups?How svm support multiclass?

Answers (2)

Walter Roberson
Walter Roberson on 21 May 2013
The way svm is defined, svm only applies to two classes. You need to change the mathematical definition of svm to apply it to multiple classes.
You can do some approximations to multi-class svm such as by using http://www.mathworks.com/matlabcentral/fileexchange/39352-multi-class-svm
Or you can use svm one class at a time, distinguishing the first class against (the union of class 2 through 79), then take the result and distinguish the second class against (the union of class 3 through 79), and so on. This is the most common approach; it is linear in the number of potential classes, and requires that you do MaxClass svm searches where MaxClass is the maximum class number that actually occurs.
You can improve the time requirements by using binary searches: (union of class 1 to 39) against (union of class 40 to 79), take the 1:39 outputs and put them through (1 to 19) vs (20 to 39), and so on. Each class that is actually present will require ceiling(log2(79)) svm runs, which is 7, so this would beat linear searching up to only floor(79/ceiling(log2(79))/2) distinct classes, on average (assuming random selection of class)
There are some theoretical papers that have extended svm to multiple classes. I have read one of the papers; it indicates that the time requirement for svm rises sharply with the number of classes. At the time the paper was written, 3 classes was slow but feasible (a fair number of hours) and 4 classes was pretty much the computation limit for a single cpu (weeks.) 79 classes... you'd probably be looking at trillions of years at least.

Dima Lisin
Dima Lisin on 15 Feb 2015
You can use the fitcecoc function in the Statistics Toolbox.

Community Treasure Hunt

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

Start Hunting!