Ask Your Question

kenli's profile - activity

2016-05-30 04:13:48 -0600 commented question Problem of predicting model via loading SVM

Thanks it's a good answer, I will try it.

2016-05-29 23:50:55 -0600 received badge  Editor (source)
2016-05-29 06:47:10 -0600 asked a question Problem of predicting model via loading SVM

OpenCV3.0.0+VS2013

The results after training is different with original predict after reloading model.

//////////////////////////////////////////////////////////////

Ptr<SVM> svm = SVM::create();

    svm->setType(SVM::C_SVC);
    svm->setKernel(SVM::RBF);
    svm->setC(1);       
    svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER, 3000, 1e-6));
    svm->setGamma(0.25);

Ptr<TrainData> tData = TrainData::loadFromCSV("20160519_r_COS.csv",1,-1,-1);
svm->train(tData, ROW_SAMPLE);

svm->save("20160519__r1.xml");              //model

Mat comp_result(predict_comp.rows, 1, CV_32FC(1));
svm->predict(predict_comp, comp_result);

Ptr<SVM> tData_comp = SVM::create();
tData_comp = StatModel::load<SVM>("20160519__r1.xml");
Mat comp_result2(predict_comp.rows, 1, CV_32FC(1));
tData_comp->predict(predict_comp, comp_result2);

the result with predict after traing is different with load model