Info

This question is closed. Reopen it to edit or answer.

DATA = {3 6 'three';21 3 'three';5 20 'five';4 6 'two';8 12 'two';9 18 'three';20 25 'five';30 15 'three';24 16 'two';10 5 'five';3 33 'three'};

1 view (last 30 days)
Classify given DATA in GROUP 'two','three' and 'five' using SVM .
How to classify given DATA in given GROUP ? please give generalize way so that i can apply on large data. Thanks

Answers (1)

Walter Roberson
Walter Roberson on 30 Jul 2013
In the first pass, temporarily relabel all samples in class 'two' and 'three' to (both) be numbered #4, leaving class 'five' as class #5. Train on that and save the resulting classifier ('A').
In the second pass, remove all samples in class #5, and train 'two' #2 vs 'three' #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 #5 or in #4. Extract the ones classified #5: those belong to class 'five'.
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 ('two') or in #3 ('three').
Now, each sample was classified as 'five' by running the first classifier, or was classified as 'two' or 'three' using the second classifier. The task is finished.
To generalize: create a classifier which distinguishes between the first class, and (everything in all other classes). Then remove all samples from the first class from consideration, and create a classifier that distinguishes between the second class and (everything that is not in the first or second class). Continue on.
In the N'th step, remove all samples from the first (N-1) classes from consideration and create a classifier that distinguishes the N'th class from (everything except the first N classes). Keep doing that until your final classifier is between the second last class and the last class.
Once you have created all of those classifiers, apply them in sequence on the unknown data. In step #N of this, if the N'th classifier classes a sample as being in the first of its two classes, then those samples belong to class #N, so remove those from consideration and keep going, applying classifier #(N+1) to what remains, until eventually all samples have been extracted or you have reached the output of the last classifier (in which cases its second class correspond to the last class of the original list of classes.)
  2 Comments
mahendra
mahendra on 30 Jul 2013
will you provide me any small demo code for your own for three group classification ,training and testing .please .
Walter Roberson
Walter Roberson on 30 Jul 2013
No, I will not. You already have code in your previous question to do a two-class classification. You have a call to train and a call to classify. Add a second call to train and a second call to classify. Most of the rest is basic "remove these rows from a matrix" code, which you can research easily in the MATLAB documentation.

Community Treasure Hunt

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

Start Hunting!