Ask Your Question
1

SVMSGD classifier not working

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

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();
svm->setOptimalParameters();

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

svm->save("svmsgd.xml");

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
0

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

berak gravatar image

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

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

Question Tools

1 follower

Stats

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

Seen: 203 times

Last updated: Dec 22 '17