# sklearn SVM really slow

I'm working with sklearn SVM and I have a problem.

When I run the method sklearn.SVM.SVC.fit() using a database with only a few features (< 10) it takes a very long time. This is weird because, when I run the same method with the same database using all of the features (> 100) it takes just a few seconds.

I'm using a polynomial kernel and this problem only appears when the degree is >= 3. And it is also weird that if I use only a few features, but I add 50 features with 0s in all the samples, it works fine!

I have tried the following experiments:

• fit() with all the features and any kernel degree. Works fine.

• fit() with a few features and kernel degree <= 2. Works fine.

• fit() with a few features and kernel degree >= 3. Very slow.

• fit() with kernel degree = 3, a few features but adding 50 features with 0s in all the samples. Works fine!!

My question is, how can I solve this? Does my trick of adding features with 0s affect the classification?

• It seems that the slow regimes correspond to those in which there are too many support vectors. Try increasing the regularization coefficient C, which penalizes slack, and monitoring the number of support vectors through clf.n_support_
– Emre
Oct 17 '17 at 3:15
• stackoverflow.com/questions/40077432/…
– G__
Jun 9 at 17:44