Why do not the parameter values ​change using the trainAuto () function of the SVM class of OpenCV 3.4?

asked 2019-07-10 18:49:19 -0600

SRG-FTL gravatar image

updated 2019-07-10 18:56:09 -0600

OpenCV says that trainAuto() function trains an SVM with optimal parameters. Every time I train with trainAuto(), the parameters that are obtained are the same. According to this, the values ​​of the parameters should change if, for example, I change the value of kFold.

I tried to change the values ​​of kFold but I still get the same values ​​in the parameters.

The code I am using is the following:

SVM svm = SVM.create();



ParamGrid cgrid = ParamGrid.create();

ParamGrid gammaGrid = ParamGrid.create();

ParamGrid pGrid = ParamGrid.create();

ParamGrid nuGrid = ParamGrid.create();

ParamGrid coeffGrid = ParamGrid.create();

ParamGrid degreeGrid = ParamGrid.create();

int kFold = 10;

svm.trainAuto(train, Ml.ROW_SAMPLE, labels, kFold, Cgrid, gammaGrid, pGrid, nuGrid, coeffGrid, degreeGrid, false);

double C = svm.getC();

double gamma = svm.getGamma();

double P = svm.getP();

double Nu = svm.getNu();

double Coef0 = svm.getCoef0();

double Degree = svm.getDegree();

System.out.println("C: " +C);

System.out.println("Gamma: " +gamma);

System.out.println("P: " +P);

System.out.println("Nu: " +Nu);

System.out.println("Coeff: " +Coef0);

System.out.println("Degree: " +Degree);

The results that I always get are the following:

C: 1.0 Gamma: 1.0 P: 0.0 Nu: 0.0 Coeff: 0.0 Degree: 0.0

What am I doing wrong?

edit retag flag offensive close merge delete