Ask Your Question

Ly's profile - activity

2016-02-29 04:32:04 -0600 commented question OpenCV SVM gives different results than libSVM

Other tests with POLY kernel gave me different results also. For instance, OpenCV after training reach 64% of accuracy on the training set, while libSVM reach 90%, with the same parameters and data.

2016-02-26 02:40:22 -0600 received badge  Good Question (source)
2016-02-25 07:25:18 -0600 commented question OpenCV SVM gives different results than libSVM

These results are for simple train, since I obtained the parameters with my own cross validation. I will investigate the distance function, although OpenCV capped a 68% for other kernels and parameters.

2016-02-25 04:08:22 -0600 received badge  Nice Question (source)
2016-02-25 03:32:03 -0600 received badge  Student (source)
2016-02-25 02:36:55 -0600 asked a question OpenCV SVM gives different results than libSVM

I've looked around for posts on the same subject but I couldn't find any similar problem. Here is my situation :

I'm running OpenCV's SVM and libSVM algorithm on the same data, with the same settings and they give very different results. On the training set, OpenCV reaches an accuracy of 68% while libSVM reaches 85%. On the test set, OpenCV reaches 53% while libSVM gives 66%.

What could explain such differences ?

I also noticed that toying around with parameters on libSVM will change my results, but if I do the same kind of tests on OpenCV, the training accuracy reaches 68% and seems to be "capped" at that value. It rarely changes except with extreme parameter values.

The latest parameters I use came from a cross validation algorithm I ran on the data. SVM type : C_SVC, kernel = RBF, gamma = 0.08192, C = 12.8

My OpenCV settings :

_svm->setTermCriteria(cv::TermCriteria(cv::TermCriteria::MAX_ITER, 10000000, 1e-5));
_svm->setType(cv::ml::SVM::C_SVC);
_svm->setKernel(cv::ml::SVM::RBF);
_svm->setGamma(0.08192);
_svm->setC(12.8);

My libsvm settings :

svm_parameter param;
param.svm_type = 0;
param.C = 12.8;
param.nu = 0;
param.nr_weight = 0;
param.weight_label = NULL;
param.weight = NULL;
param.cache_size = 50;
param.eps = 1e-5;
param.p = 0;
param.shrinking = 0;
param.probability = 0;
param.kernel_type = 2;
param.degree = 0;
param.gamma = 0.08192;
param.coef0 = 0;