This repository is meant to provide an easy-to-use implementation of the SVM classifier using the Stochastic Gradient Descent.
This approach followed the one presented in Bottou, Léon. "Large-scale machine learning with stochastic gradient descent." Proceedings of COMPSTAT'2010. Physica-Verlag HD, 2010. 177-186. To run the code you need OpenCV. For a non-dependent OpenCV implementation you just need to substitute the Mats for float arrays as well as remove all OpenCV dependencies (I pretend to do the same later).
News: SVMSGD was submitted to the OpenCV library. I would like to thank to Marina Noskova ([email protected]) for refactoring the code to be consistent with the existing ml classifiers.
Original PR: opencv/opencv#5291
Refactored PR: opencv/opencv#6096
To use the SVM classifier you just need to create the object:
SvmSgd SVMSGD;
or
SvmSgd SVMSGD(updateFrequency);
And train the classifier with your training features and the corresponding labels:
SVMSGD.train(trainFeatures, labels);
After that you can predict the label of your new feature vector:
predictedLabel = SVMSGD.predict(predictFeatures.row(i));
The main advantage when compared to others SVM classifiers (like the one present in OpenCV, for example) is the speed performance and the online update of the wheights.
The out.avi shows the performance of the presented classifier when used to classify cars using HOG features. As can be seen, the cars are correctly classified.
You can contact me by email: [email protected]