How to do multi class classification using Support Vector Machines (SVM)

Viewed 94028

In every book and example always they show only binary classification (two classes) and new vector can belong to any one class.

Here the problem is I have 4 classes(c1, c2, c3, c4). I've training data for 4 classes.

For new vector the output should be like

C1 80% (the winner)

c2 10%

c3 6%

c4 4%

How to do this? I'm planning to use libsvm (because it most popular). I don't know much about it. If any of you guys used it previously please tell me specific commands I'm supposed to use.

8 Answers

Commonly used methods are One vs. Rest and One vs. One. In the first method you get n classifiers and the resulting class will have the highest score. In the second method the resulting class is obtained by majority votes of all classifiers.

AFAIR, libsvm supports both strategies of multiclass classification.

You can always reduce a multi-class classification problem to a binary problem by choosing random partititions of the set of classes, recursively. This is not necessarily any less effective or efficient than learning all at once, since the sub-learning problems require less examples since the partitioning problem is smaller. (It may require at most a constant order time more, e.g. twice as long). It may also lead to more accurate learning.

I'm not necessarily recommending this, but it is one answer to your question, and is a general technique that can be applied to any binary learning algorithm.

For multi class classification using SVM; It is NOT (one vs one) and NOT (one vs REST).

Instead learn a two-class classifier where the feature vector is (x, y) where x is data and y is the correct label associated with the data.

The training gap is the Difference between the value for the correct class and the value of the nearest other class.

At Inference choose the "y" that has the maximum value of (x,y).

y = arg_max(y') W.(x,y') [W is the weight vector and (x,y) is the feature Vector]

Please Visit link: https://nlp.stanford.edu/IR-book/html/htmledition/multiclass-svms-1.html#:~:text=It%20is%20also%20a%20simple,the%20label%20of%20structural%20SVMs%20.

Related