Ask Your Question

eipoa's profile - activity

2017-05-04 10:55:31 -0600 received badge  Student (source)
2017-05-04 10:43:45 -0600 asked a question is the sigmoid kernel in SVM same as it in LIBSVM?
        Ptr<SVM> svm = SVM::create();
        svm->setType(SVM::C_SVC);
        svm->setKernel(3);
        svm->setDegree(3); // have to set the param, runtime error
        svm->setTermCriteria(TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 1000, 0.01));
        svm->trainAuto(_Samples, 10, SVM::getDefaultGrid(SVM::C), SVM::getDefaultGrid(SVM::GAMMA),
        SVM::getDefaultGrid(SVM::P), SVM::getDefaultGrid(SVM::NU), SVM::getDefaultGrid(SVM::COEF),
        SVM::getDefaultGrid(SVM::DEGREE), true);
        svm->predict(Test, results);

using LIBSVM with sigmoid can achieve 86% of accuracy, but using cv can only get about 40%. what's wrong with my code?

2017-05-04 10:32:19 -0600 commented question Problem training SVM with sigmoid kernel

the performance of sigmoid kernel in opencv is quite worst than it in LIBSVM. but other kernels look same as them in LIBSVM

2017-05-04 09:23:49 -0600 commented question 3.2.0 SVM OpenCV Error: Assertion failed (samples.cols == var_count && samples.type() == CV_32F) in predict, file C:/repo/mingw-w64-opencv/src/opencv-3.2.0/modules/ml/src/svm.cpp, line 1930

I want to test which combinations of features are more important. the varidx works when using bayes classifier. i thing they shuld be the same cause they are all the children of StatModel. anyway, i think that maybe after useing setTrainTestSplitRatio() to divied data into train and test, the varidx may work well. but unfortunately, after this it doesn't work when i call pridect(). i mean the following the steps donot work at all. 1. setTrainTestSplitRatio 2. train 3. predict i forgot the error message, it seems that data type error., but after spliting, no way to change data type. i donot know whether the ml pass the test.

2017-05-02 04:43:20 -0600 asked a question 3.2.0 SVM OpenCV Error: Assertion failed (samples.cols == var_count && samples.type() == CV_32F) in predict, file C:/repo/mingw-w64-opencv/src/opencv-3.2.0/modules/ml/src/svm.cpp, line 1930

OpenCV Error: Assertion failed (samples.cols == var_count && samples.type() == CV_32F) in predict, file C:/repo/mingw-w64-opencv/src/opencv-3.2.0/modules/ml/src/svm.cpp, line 1930

vector<int> Idx {1,2,3,4,5,6,7,8,9,10,11,13};//0,1,2,3,4,5,6,7,8,9,10,11,12,13; (14 features)
Mat varIdx(Idx);
Ptr<TrainData> _Samples = TrainData::create(Train, ROW_SAMPLE, TrainResp, _Params.getVarIdx());
Ptr<NormalBayesClassifier> normalBayesClassifier = StatModel::train<NormalBayesClassifier>(_Samples);
normalBayesClassifier->predict(Test, results);
......
svm->trainAuto(_Samples);
svm->predict(Test, results);// error

the varidx for svm doesnot work, but for Bayes it works, at least the program doesnot crash. I checked some answers from google, someone said varidx should be like this {0,1,1,1,1,0,1...}, it is so strange, i cannot believe it.