Ask Your Question

Revision history [back]

Stochastic Gradient Descent SVM and RAW_OUTPUT

I'm trying to implement the Stochastic Gradient Descent SVM in order to get an incremental version of the SVM. The problem is that I noted that the function related to this is not configured in order to output the score information of the prediction of the SVM, it just show the class label. I am using the Python API in Windows 7.

svm = cv2.ml.SVMSGD_create()
svm.setOptimalParameters()
svm.setTermCriteria((cv2.TERM_CRITERIA_COUNT, 100, 1.e-06))

DATA = cv2.ml.TrainData_create(trainData, cv2.ml.ROW_SAMPLE,  labels)
svm.train( DATA, cv2.ml.STAT_MODEL_UPDATE_MODEL)
svm.predict(candidate, flags = cv2.ml.STAT_MODEL_RAW_OUTPUT)[1][0,0]

The result is always the same with or without the flag:

cv2.ml.STAT_MODEL_RAW_OUTPUT

Looking into the core code of OpenCV library I think that in the definition of the predict function of SGDSVM there is no reference to this flag.

float SVMSGDImpl::predict( InputArray _samples, OutputArray _results, int ) const

Comparing to the normal SVM.

float predict( InputArray _samples, OutputArray _results, int flags ) const CV_OVERRIDE

Am I doing something wrong?