How to adjust parameter of SVM for better training

Issue

I am working on a Linear SVM and I am using Opencv with Python, I am trying to adjust the parameters for better training but still not getting the good results, I am feeling that I am going through wrong parameter setting,

# Create SVM classifier
svm = cv2.ml.SVM_create()
svm.setType(cv2.ml.SVM_EPS_SVR)
svm.setKernel(cv2.ml.SVM_LINEAR)
#cv2.ml.SVM_LINEAR
svm.setDegree(3)
svm.setGamma(1)
svm.setCoef0(0.0)
svm.setC(0.01)
svm.setNu(0.5)
svm.setP(0.1)
#svm.setClassWeights(0)

I am using above parameters and taking lot of help from here.

Solution

You’d getter better results with searching for the optimal parameter values using trainAuto. You cannot copy the param values from some other application and expect to get good results on your own data.

When you call say svm.getType() you get an int value, for example 100. To understand then the type see this page, under Public Types you find this:

enum Types { C_SVC =100, NU_SVC =101, ONE_CLASS =102,
EPS_SVR =103, NU_SVR =104 }

Hence, 100 means C_SVC. And for the kernel type you find:

enum KernelTypes { CUSTOM =-1, LINEAR =0, POLY =1, RBF
=2, SIGMOID =3, CHI2 =4, INTER =5 }

Then 2 means the RBF kernel yields the best accuracy on your data.

Answered By – fireant

Answer Checked By – Dawn Plyler (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.