unexpected performance using SVM with RBF kernel

asked 2014-10-12 15:17:26 -0600

fnhdx gravatar image

updated 2014-10-13 08:08:28 -0600

I am kind of new to svm classification. I am trying to use opencv svm classifier to do some face recognition. The input feature parameters are normalized Local binary pattern. So all values are from 0-1. I first tried linear kernel to train the classifier and then use the training data set to test set. I got 100% accuracy ( I know it means nothing). However, when I changed kernel to RBF (all other parameters are default) and re-test the training set, all cases are classified to one class which means they are not separable. I tried different gamma values from 0.000001 to 10. Does anyone have idea about this issue? Thanks.

CvSVMParams param;
param.svm_type = CvSVM::C_SVC;
param.kernel_type = CvSVM::RBF; //CvSVM::RBF, CvSVM::LINEAR ...
param.degree = 2; // for poly
param.gamma = 0.000000001; // for poly/rbf/sigmoid
param.coef0 = 1; // for poly/sigmoid

param.C = 0.5; // for CV_SVM_C_SVC, CV_SVM_EPS_SVR and CV_SVM_NU_SVR
param.term_crit.type = CV_TERMCRIT_EPS;//CV_TERMCRIT_ITER +CV_TERMCRIT_EPS;
param.term_crit.max_iter = 1000000;
param.term_crit.epsilon = 1e-9;
SVM.train(trainingDataMat, labelMat, Mat(), Mat(), param);

for(int i=0; i<trainingDataMat.rows; i++){
    Mat sampleMat = trainingDataMat(Range(i,i+1), Range::all());
    double response = SVM.predict(sampleMat);
    cout<<"test"<<i<<"=  "<<response<<endl;
}
edit retag flag offensive close merge delete

Comments

1

just some thoughts:

  • for multi-class svm, a POLY kernel worked quite nicely for me.
  • "The input feature parameters are normalized Local binary pattern. So all values are from 0-1" this sounds wrong. ppl usually take histograms ( of grid patches ) of the lbp image, and use that for features. (normalized or not)
berak gravatar imageberak ( 2014-10-13 02:23:04 -0600 )edit

Sorry for the confusion. The input should be normalized lbp histogram. Also, it's two class svm.

fnhdx gravatar imagefnhdx ( 2014-10-13 07:56:02 -0600 )edit

@berak, are you maybe up to making some machine learning tutorials? I have the idea that many people do not succeed in processing this module as they are supposed to.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-10-14 06:18:07 -0600 )edit