1
$\begingroup$

I was trying to apply SVM into a dataset to find its accuracy. I also applied bagging and boosting on the same dataset and they worked properly. But when I tried to fit SVM into a model its not working. I couldn't understand whats the problem.

I'm providing the sample of my dataset

train_new.head()

enter image description here

# define X and y feature_cols = ['age','workclass','fnlwgt','education','education-num','marital-status','occupation','relationship','race','sex','capital-gain','capital-loss','hours-per-week','native-country']

# X is a matrix, hence we use [] to access the features we want in feature_cols X = train_new[feature_cols]

# y is a vector, hence we use dot to access 'label' y = train_new['label']

from sklearn import svm model = svm.SVC(kernel='linear', C=1, gamma=1)

and while trying to fit with model it's almost minutes passed and it's just look like,

enter image description here

What's the actual problem and could I solve it ?

| improve this question | | | | |
$\endgroup$
  • $\begingroup$ How big is your dataset? Can you post any error message as well? $\endgroup$ – vc_dim Jan 13 '18 at 13:21
  • $\begingroup$ The dataset has 15 attributes with 30161 instances. And there are no error message but it looks like the posted last image. $\endgroup$ – IS2057 Jan 13 '18 at 13:47
  • $\begingroup$ Test it first. SVC's generally take a large amount of time to run - and they also become more slower as more variables are added. Maybe try trimming down the variables and re-running. FYI: mins isn't a long time! $\endgroup$ – plumbus_bouquet Jan 14 '18 at 22:45
  • $\begingroup$ Make sure to enable verbose, you may pick something up. At least you could show us the output. $\endgroup$ – Grzegorz Jan 15 '18 at 14:01
1
$\begingroup$

15 attributes with 30161 instances are not much to cause this delay, I've trained with much more. Your system config also plays a major role in this. For instance if you are using anaconda on chrome and you have multiple processes going on then it would cause delay as distances are calculated on the fly which will be heavy on memory.

You can also try SGD as you are going for linear. It is faster than SVM.

| improve this answer | | | | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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