Question

I am doing face recognition using PCA and SVM. Using libSVM for SVM implementation in matlab. I am trying to implement one vs all classification. I have a threefold question.

First : I have 10 images in class 1(of face 1) then class 2 should have 60 images (10 images each of the 6 faces) ?

Second: Will the accuracy depend on the number of images I take in both the classes? If yes, then Can accuracy become 100%(unreasonably high) due to large number of images in class two?

Third: Can a single image be used for testing?

Any help will be deeply appreciated.

Was it helpful?

Solution

You are asking three questions:

(1) EDIT: Yes, exactly as you explained it in the comments. If you have 7 classes you would train 7 classifiers. For each classifiers i you would train for the positive class images of individual i, and for the negative class images of all other individuals.

What you describe is called one-vs-all classification and it is a commonly used method to do multi class classification with a base binary classifier (such as an SVM). Let me also add that there are other methods used to extend binary classifiers to multi-class classification such as one-vs-one and error correcting tournaments.

EDIT #2: Let me add that one-vs-one classification is already implemented in LIBSVM you really don't have to do anything special. All you need to do is add distinct doubles to each of the classes in the training data (so you could use classes 0, 1, ... 7).

If you really want to do one vs all (also called one vs the rest) you can do use it too. Since it seems you're using MATLAB, there is code (it is not directly implemented in LIBSVM) but the authors of LIBSVM make available code to implement that: direct link to FAQs

(2) The accuracy will depend on the number of images. In ideal conditions you will have many images of all individuals to train with. But you can get in situations such as imbalanced datasets, that can occur for example if you train with a million images of class x and only 2 images of class y, and 2 images of class z, you will have problems because your classifier gets a more detailed view of class x than of the other two classes. To evaluate you will need a full confusion matrix (i.e. how many real objects of class x are classifier as class y and how many real objects of class y are classified as class x and so on for every pair of classes).

(3) Yes, it can.

EDIT #3:

It seems, from the comments of the authors of LIBSVM, that the accuracy of one-vs-one is similar to the accuracy of one-vs-all, with the difference that it is faster to train one-vs-one, and that is the reason why they implement one-vs-one in their system.

To train a multi-class model using LIBSVM you would use svmtrain and invoke it only once. Class 1 are images of individual 1, Class 2 are images of individual 2, ... class 7 are images of individual 7.

To predict, after training your model you would use svmpredict

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top