svm multiclass classifier predicts same class for all objects

asked 2019-04-21 13:02:55 -0600

bm gravatar image

updated 2019-04-22 05:13:01 -0600

berak gravatar image

I have 14 classes of images - these are sampled from a kinect video of 14 objects. Using HOG for feature extraction and SVM for classification. There are 20 training samples for each class. I have also tried KAZE feature extractor and Random Forest, but the same class is predicted for all. what am I doing wrong?

These are the parameters used for SVM
////create and train the svm 
//Ptr<ml::SVM> svm = SVM::create();
//svm->setKernel(SVM::RBF);
//svm->setType(SVM::C_SVC);
////Ptr<ml::ParamGrid> nogrid = ml::ParamGrid::create(0, 0, 0);//no need nu, coeff0 or p
//auto td = TrainData::create(mat, ROW_SAMPLE, labels);
//ParamGrid Cgrid = SVM::getDefaultGrid(SVM::C);
//ParamGrid pGrid = SVM::getDefaultGrid(SVM::P);
//ParamGrid gammaGrid = SVM::getDefaultGrid(SVM::GAMMA);
//ParamGrid nuGrid = SVM::getDefaultGrid(0);
//ParamGrid coeffGrid = SVM::getDefaultGrid(SVM::COEF);
//ParamGrid degreeGrid = SVM::getDefaultGrid(0);

//svm->trainAuto(td,30,Cgrid,gammaGrid,pGrid,nuGrid,coeffGrid,degreeGrid,true);

Thanks for any help

edit retag flag offensive close merge delete

Comments

sadly, it's unclear now, what is actually used, and what is commented away ;(

there may also be errors in assembling your train data / label, and we can't see it.

berak gravatar imageberak ( 2019-04-22 05:53:02 -0600 )edit

There are 20 training samples for each class

ridicullously low. you need 100x the data

berak gravatar imageberak ( 2019-04-22 05:53:58 -0600 )edit

I have also tried KAZE feature extractor

please look up on (binary !!) features, metrics / distance formulas. most likely your data does not make sense with the given ml algo.

berak gravatar imageberak ( 2019-04-22 05:55:47 -0600 )edit

I'm getting stuck with the same problem.The model allways predicts the same class. Did you find an answer for that?

dangnh gravatar imagedangnh ( 2019-05-28 13:15:04 -0600 )edit