# Revision history [back]

### CvSVM::EPS_SVR train_auto assertion sv_count != 0 failed

I have the following code:

CvSVMParams params;
params.svm_type = CvSVM::EPS_SVR;
params.kernel_type = CvSVM::RBF;
params.term_crit = TermCriteria(CV_TERMCRIT_ITER, (int)1e7, 1e-6);

CvSVM svm;
svm.train_auto(_data, _resp, _var_idx, _train_idx, params);


Here _data and _resp are Mats holding the feature vectors and responses, _var_idx containing the active features and _train_idx the active samples. For the parameter grids the default values are used. Unfortunately, the code produces the following error:

OpenCV Error: Assertion failed (sv_count != 0) in do_train, file /home/.../opencv-2.4.9/modules/ml/src/svm.cpp, line 1346

When I run a regression one the same data with parameters selected by hand it works fine. And when I switch to a classification problem (and change the corresponding parameters and SVM type) it also works. In that case for single training as well as for auto training. Also, when switching to CvSVM::NU_SVR the auto training works fine.

Another thing that bothers me is that I also have to provide the parameter p (EPS_EVR) or nu (NU_SVR) when I want to do auto training. The documentation says that those are also estimated using their corresponding default grids. Why is that so?

### CvSVM::EPS_SVR train_auto assertion sv_count != 0 failed

I have the following code:

CvSVMParams params;
params.svm_type = CvSVM::EPS_SVR;
params.kernel_type = CvSVM::RBF;
params.term_crit = TermCriteria(CV_TERMCRIT_ITER, (int)1e7, 1e-6);

CvSVM svm;
svm.train_auto(_data, _resp, _var_idx, _train_idx, params);


Here _data and _resp are Mats holding the feature vectors and responses, _var_idx containing the active features and _train_idx the active samples. For the parameter grids the default values are used. Unfortunately, the code produces the following error:

OpenCV Error: Assertion failed (sv_count != 0) in do_train, file /home/.../opencv-2.4.9/modules/ml/src/svm.cpp, line 1346

When I run a regression one the same data with parameters selected by hand it works fine. And when I switch to a classification problem (and change the corresponding parameters and SVM type) it also works. In that case for single training as well as for auto training. Also, when switching to CvSVM::NU_SVR the auto training works fine.

Another thing that bothers me is that I also have to provide the parameter p (EPS_EVR) or nu (NU_SVR) when I want to do auto training. The documentation says that those are also estimated using their corresponding default grids. Why is that so?

### CvSVM::EPS_SVR train_auto assertion sv_count != 0 failed

I have the following code:

CvSVMParams params;
params.svm_type = CvSVM::EPS_SVR;
params.kernel_type = CvSVM::RBF;
params.term_crit = TermCriteria(CV_TERMCRIT_ITER, (int)1e7, 1e-6);

CvSVM svm;
svm.train_auto(_data, _resp, _var_idx, _train_idx, params);


Here _data and _resp are Mats holding the feature vectors and responses, _var_idx containing the active features and _train_idx the active samples. For the parameter grids the default values are used. Unfortunately, the code produces the following error:

OpenCV Error: Assertion failed (sv_count != 0) in do_train, file /home/.../opencv-2.4.9/modules/ml/src/svm.cpp, line 1346

When I run a regression one the same data with parameters selected by hand it works fine. And when I switch to a classification problem (and change the corresponding parameters and SVM type) it also works. In that case for single training as well as for auto training. Also, when switching to CvSVM::NU_SVR the auto training works fine.

Another thing that bothers me is that I also have to provide the parameter p (EPS_EVR) or nu (NU_SVR) when I want to do auto training. The documentation says that those are also estimated using their corresponding default grids. Why is that so?

EDIT:

I've made a small example that suffers from this problem. Just in case anyone want to try it out and reproduce the problem:

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/ml/ml.hpp>

using namespace cv;
using namespace std;

int main() {

Mat X(1000, 2, CV_32FC1);
Mat Y(1000, 1, CV_32FC1);

randu(X, -2, 2);

for(int i = 0; i < 1000; i++){
Y.at<float>(i,0) = pow(X.at<float>(i,0),2) + pow(X.at<float>(i,1),2) - 1;
}

CvSVMParams params;
params.svm_type = CvSVM::EPS_SVR;
params.kernel_type = CvSVM::RBF;
params.term_crit = TermCriteria(CV_TERMCRIT_ITER, (int)1e7, 1e-6);
params.p = 0.1;

CvSVM svm;
svm.train_auto(X, Y, Mat::ones(1,2, CV_8U), Mat::ones(1,1000, CV_8U), params);

return 0;
}