# Support Vector Classification kernels ‘linear’, ‘poly’, ‘rbf’ has all same score

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

• 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. Jun 24, 2016 at 10:40
• Thank you. Solved with the parameters and all works fine now.
– n1tk
Jun 30, 2016 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!

• Same results ... in R does provide the correct scores ...
– n1tk
Jun 23, 2016 at 5:14
• works now on separate notebooks and also with parameters updated. Thank you.
– n1tk
Jun 30, 2016 at 4:48