Commit 9bba98c9 authored by Guillaume Pasero's avatar Guillaume Pasero

ENH: expose additional parameters in SVM regression application

parent a78e2e13
......@@ -67,6 +67,20 @@ namespace Wrapper
AddParameter(ParameterType_Float, "classifier.svm.p", "Parameter epsilon of a SVM optimization problem (EPS_SVR)");
SetParameterFloat("classifier.svm.p", 1.0);
SetParameterDescription("classifier.svm.p", "Parameter epsilon of a SVM optimization problem (EPS_SVR).");
AddParameter(ParameterType_Choice, "classifier.svm.termcrit", "Termination criteria");
SetParameterDescription("classifier.svm.termcrit","Termination criteria for iterative algorithm");
AddChoice("classifier.svm.termcrit.iter", "Stops when Max_iteration is reached.");
AddChoice("classifier.svm.termcrit.eps", "Stops when accuracy is lower than epsilon.");
AddChoice("classifier.svm.termcrit.itereps", "Stops when either iteration or epsilon criteria is true");
AddParameter(ParameterType_Float, "classifier.svm.maxiter", "Maximum iteration");
SetParameterFloat("classifier.svm.maxiter", 1000);
SetParameterDescription("classifier.svm.maxiter", "Maximum number of iterations (corresponds to the termination criteria 'iter').");
AddParameter(ParameterType_Float, "classifier.svm.epsilon", "Epsilon accuracy threshold");
SetParameterFloat("classifier.svm.epsilon", FLT_EPSILON);
SetParameterDescription("classifier.svm.epsilon", "Epsilon accuracy (corresponds to the termination criteria 'eps').");
}
AddParameter(ParameterType_Float, "classifier.svm.coef0", "Parameter coef0 of a kernel function (POLY / SIGMOID)");
SetParameterFloat("classifier.svm.coef0", 0.0);
......@@ -168,6 +182,23 @@ namespace Wrapper
if (this->m_RegressionFlag)
{
SVMClassifier->SetP(GetParameterFloat("classifier.svm.p"));
switch (GetParameterInt("classifier.svm.termcrit"))
{
case 0: // ITER
SVMClassifier->SetTermCriteriaType(CV_TERMCRIT_ITER);
break;
case 1: // EPS
SVMClassifier->SetTermCriteriaType(CV_TERMCRIT_EPS);
break;
case 2: // ITER+EPS
SVMClassifier->SetTermCriteriaType(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS);
break;
default:
SVMClassifier->SetTermCriteriaType(CV_TERMCRIT_ITER);
break;
}
SVMClassifier->SetMaxIter(GetParameterInt("classifier.svm.maxiter"));
SVMClassifier->SetEpsilon(GetParameterFloat("classifier.svm.epsilon"));
}
SVMClassifier->SetCoef0(GetParameterFloat("classifier.svm.coef0"));
SVMClassifier->SetGamma(GetParameterFloat("classifier.svm.gamma"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment