Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I want to attempt to use Support Vector Machines (SVMs) on my dataset. Before I attempt the problem though, I was warned that SVMs dont perform well on extremely unbalanced data. In my case, I can have as much as 95-98% -1's and 2-5% 1's.

I tried to find resources which talked about using SVMs on sparse/unbalanced data, but all I could find was 'sparseSVMs' (which use a small amount of support vectors).

I was hoping someone could briefly explain:

1) how well SVM would be expected to do with such a dataset
2) which, if any, modifications must be done to the SVM algorithm 3) what resources/papers discuss this


share|improve this question

3 Answers 3

Many SVM implementations address this by assigning different weights to positive and negative instances. Essentially you weigh the samples so that the sum of the weights for the positives will be equal to that of the negatives. Of course, in your evaluation of the SVM you have to remember that if 95% of the data is negative, it is trivial to get 95% accuracy by always predicting negative. So you have to make sure your evaluation metrics are also weighted so that they are balanced.

Specifically in libsvm, which you added as a tag, there is a flag that allows you to set the class weights (-w I believe, but check the docs).

Finally, from personal experience I can tell you that I often find that an SVM will yield very similar results with or without the weight correction.

share|improve this answer
Beat me to it :-) –  Marc Claesen Apr 18 at 20:58

SVMs work fine on sparse and unbalanced data. Class-weighted SVM is designed to deal with unbalanced data by assigning higher misclassification penalties to training instances of the minority class.

share|improve this answer

In the case of sparse data like that SVM will work well.

As stated by @Bitwise you should not use accuracy to measure the performance of the algorithm.

Instead you should calculate the precision, recall and F-Score of the algorithm.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.