I build a classification model based on SVM and getting same results after running different kernels. Can you please let me know if is mistake ? also recall for all are identical. Thank you for help.

Adding the location for the notebook and data. SVC repo with the notebook and data

Support Vector Classification scores

Accuracy score

recall score

  • $\begingroup$ recall=0 shows that predictions for all classifiers are constantly negative, so accuracy is simply the proportion of negative elements in the test set. Try making the training set more balanced by using class_weight parameter or by subsampling. $\endgroup$ – Valentas Jun 24 '16 at 10:40
  • $\begingroup$ Thank you. Solved with the parameters and all works fine now. $\endgroup$ – n1tk Jun 30 '16 at 4:47

You will love the answer to this one...

Take a look at your code and notice that you are calling the scoring function and each time you are passing in the exact same values i.e. they are all spitting out the lin_svc.score(). Try interweaving the four scoring calls below the four respective fit calls and you should see the desired variation in the result.

# we create an instance of SVM and fit out data. We do not scale our
# data since we want to plot the support vectors
#rbf is for gaussian
C = 1.0  # SVM regularization parameter

svc = svm.SVC(kernel='linear', C=C).fit(X_train, y_train)
print svc.score(X_test, y_test)

rbf_svc = svm.SVC(kernel='rbf', gamma=0.7, C=C).fit(X_train, y_train)
print rbf_svc.score(X_test, y_test)

poly_svc = svm.SVC(kernel='poly', degree=3, C=C).fit(X_train, y_train)
print poly_svc.score(X_test, y_test)

lin_svc = svm.LinearSVC(C=C).fit(X_train, y_train)
print lin_svc.score(X_test, y_test)

Similarly, you are doing the same thing below also.

Hope this helps!

  • 1
    $\begingroup$ Same results ... in R does provide the correct scores ... $\endgroup$ – n1tk Jun 23 '16 at 5:14
  • 1
    $\begingroup$ works now on separate notebooks and also with parameters updated. Thank you. $\endgroup$ – n1tk Jun 30 '16 at 4:48

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.