Ask Your Question

Revision history [back]

svm multiclass classifier predicts same class for all objects

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

click to hide/show revision 2
None

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

berak gravatar image

svm multiclass classifier predicts same class for all objects

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> //Ptr<ml::SVM> svm = SVM::create();
 //svm->setKernel(SVM::RBF);
 //svm->setType(SVM::C_SVC);
 ////Ptr<ml::paramgrid> ////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::getDefaultGrid(0);
//svm->trainAuto(td,30,Cgrid,gammaGrid,pGrid,nuGrid,coeffGrid,degreeGrid,true);

Thanks for any help