Ask Your Question
5

OpenCV's svm and libsvm, the difference and how to make them the same

asked 2014-08-19 09:26:11 -0600

cysin gravatar image

Hi there, I am evaluating OpenCV's SVM and libsvm 3.18 but surprisingly they have different results. It's said OpenCV's SVM is based on libsvm but OpenCV's SVM is much faster during training and has a higher accuracy. All tests were done with the same parameters and training dataset.

So what's the difference between the two svm libs and how to make them perform exactly the same(I mean the accuracy)?

edit retag flag offensive close merge delete

Comments

3

That's really surprising! I think OpenCV SVM is based on LibSVM (http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf), which--perhaps-- means OpenCV developers optimized the code better than the LibSVM's! I mean the source code differs, but the idea is the same.

hadoofi gravatar imagehadoofi ( 2014-08-19 10:28:30 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
4

answered 2014-08-22 21:18:19 -0600

cysin gravatar image

I made a mistake when testing the accuracy and actually I was comparing the 'svm_predict' and 'svm_predict_probability'. These two functions may return different results even all the parameters are the same. In my case 'svm_predict' has a hight accuracy. And if you enable probability it might need more time during training(to calculate the probabilites). OpenCV also has optimized some basic math functions with SIMD, like 'exp', so it might be faster when doing kernel calculations which need exp.

Hope this will be helpful to someone who met the same question as me

edit flag offensive delete link more

Comments

1

Do accept your own answer so that this becomes solved! Thanks for the info!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-23 04:33:23 -0600 )edit

Question Tools

Stats

Asked: 2014-08-19 09:26:11 -0600

Seen: 1,047 times

Last updated: Aug 22 '14