2
votes

I have a text data labelled into 3 classes and class 1 has 1% data, class 2 - 69% and class 3 - 30%. Total data size is 10000. I am using 10-fold cross validation. For classification, SVM of scikit learn python library is used with class_weight=auto. But the code for 1 step of 10-fold CV has been running for 2 hrs and has not finished. This implies that for code will take at least 20 hours for completion. Without adding the class_weight=auto, it finishes in 10-15min. But then, no data is labelled of class 1 in the output. Is there some way to achieve solve this issue ?

1

1 Answers

4
votes

First, for text data you don't need a non linear kernel, so you should use an efficient linear SVM solver such as LinearSVC or PassiveAggressiveClassifier instead.

The SMO algorithm of SVC / libsvm is not scalable: the complexity is more than quadratic which is practice often makes it useless for dataset larger than 5000 samples.

Also to deal with the class imbalance you might want to try to subsample the class 2 and class 3 to have a number of samples maximum twice the number of samples of class 1.