Ask Your Question
0

SVM training error: is not integral in function cvPreprocessCategoricalResponses

asked 2017-05-23 06:59:22 -0600

waschbaer gravatar image

updated 2017-05-23 07:00:28 -0600

I am now training the svm for binary classifier problems. positive label is +1, and negative label is -1. The trainingData is just histogramm of hue with 180 bins. Totally there are 70 samples.

The problem appears as following:

SVM.train(trainingData, labels, Mat(), Mat(), params);

where trainingData is a 70 by180 one channel matrix and labels is a 70 by 1 one channel matrix. The matrices are constructed as following:

Mat trainingData(70,180,CV_32FC1); Mat labels(70,1,CV_32FC1);

The error is: OpenCV Error: Bad argument (response #0 is not integral) in cvPreprocessCategoricalResponses, file /home/adminics/Downloads/opencv-2.4.13/modules/ml/src/inner_functions.cpp, line 715 terminate called after throwing an instance of 'cv::Exception' what(): /home/adminics/Downloads/opencv-2.4.13/modules/ml/src/inner_functions.cpp:715: error: (-5) response #0 is not integral in function cvPreprocessCategoricalResponses

Aborted (core dumped)

I saw some people had same problems as me. But no solutions yet.

Thank you. Best, waschbear

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-05-23 07:32:01 -0600

berak gravatar image

updated 2017-05-23 07:36:02 -0600

SVM labels should be integer in case of a classification (float, if you wanted a regression) , the type of the matrix is relevant here, so make it:

Mat labels(70,1,CV_32SC1);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-05-23 06:59:22 -0600

Seen: 378 times

Last updated: May 23 '17