2013-09-04 08:48:21 -0500 commented question ML - Exception in CvSVM::predict when using NU_SVC as type TrainOut is just a name for the expected output. I tried to save the model but it just crashes without extra messages. It seems something goes wrong during the training. If i do the same thing with C_SVC everything goes well 2013-09-04 04:22:49 -0500 asked a question ML - Exception in CvSVM::predict when using NU_SVC as type I have some simple code, which works: CvSVM svm; CvSVMParams svmparams; // svmparams.svm_type = CvSVM::C_SVC; svmparams.kernel_type = CvSVM::RBF; svmparams.gamma = 1.0; svmparams.coef0 = 0.0; svmparams.C = 0.5; svmparams.nu = 0.5; ... load the dataset svm.train(trainIn, trainOut, 0, 0, svmparams); ... for (int v = 0; v < validateIn->rows; v++) { cvGetRow(validateIn, &sample, v); cat = validateOut->data.fl[v]; float r = 0.0; r = svm.predict(&sample); ... }  My problem is that as soon as i set svmparams.svm_type = CvSVM::NU_SVC;  i get the following runtime error: OpenCV Error: Bad argument (The SVM should be trained first) in CvSVM::predict, file E:\Dev\new\opencv\modules\ml\src\svm.cpp, line 2129 terminate called after throwing an instance of 'cv::Exception' what(): E:\Dev\new\opencv\modules\ml\src\svm.cpp:2129: error: (-5) The SVM should be trained first in function CvSVM::predict It seems as if it ignores the training when NU_SVC is set. Any ideas?