Ask Your Question

SVMSGD classifier not working

asked 2017-12-21 09:05:08 -0500

opencv_user99 gravatar image

I'm trying to use the SVMSGD classifier in OpenCV 3.3.1 but I'm struggling to get any kind of result. Here is an excerpt of the relevant code I am using right now.

cv::Ptr<cv::ml::SVMSGD> svm = cv::ml::SVMSGD::create();

cv::Ptr<cv::ml::TrainData> tdata = cv::ml::TrainData::create(train_data, cv::ml::ROW_SAMPLE, truth_data);


But even when I change the SVMSGD parameters the training is always almost instantaneous and the weights saved in the xml files are always all zeros. (and of course i get poor accuracy results) The other classifiers like the SVM work fine so there shouldn't be any problems with the data.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-12-22 03:29:19 -0500

berak gravatar image

updated 2017-12-22 04:24:57 -0500

looking at the implementation -- it seems you need [-1,1] labels for this ;)

if all your truth_data is positive, there is no need to train anything, because all your samples are on the "same side" of the support vector

(it's also a binary classifier only, unlike cv::SVM it canhandle only 2 classes)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-12-21 09:05:08 -0500

Seen: 97 times

Last updated: Dec 22 '17