I am using opencv to develop a very simple classifer for image. I want to use svm type poly but it gives error while other like sigmoid, RBF works fine. I defined the parameters as follows:
SVMParams params;
params.svm_type = SVM::C_SVC;
params.kernel_type = SVM::POLY;
params.gamma = 20;
params.degree = 0;
params.coef0 = 0;
params.C = 7;
params.nu = 0.0;
params.p = 0.0;
params.class_weights = NULL;
params.term_crit.type = CV_TERMCRIT_ITER +CV_TERMCRIT_EPS;
params.term_crit.max_iter = 1000;
params.term_crit.epsilon = 1e-6;
The error reads openCV Error: One of arguments' values is out of range (The kernel parameter must be positive) in CvSVM::set_params. I am unsure what is the error about.?
For a polynomial kernel, degree must be larger than 1 (0 is invalid, 1 is linear). For most packages, the default value for degree is 3.
RBF and sigmoid kernels work fine with your settings because they don't use degree. For reference, the kernel functions in question are:
k(u,v)=(gamma*u'*v + coef0)^degree,k(u,v)=exp(-gamma*|u-v|^2),k(u,v)=tanh(gamma*u'*v + coef0).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With