Skip to content
Snippets Groups Projects
Commit a78e2e13 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: expose usefull parameter for LibSVM regression

parent 95a5a18a
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,21 @@ namespace Wrapper
AddChoice("classifier.libsvm.k.sigmoid", "Sigmoid");
SetParameterString("classifier.libsvm.k", "linear");
SetParameterDescription("classifier.libsvm.k", "SVM Kernel Type.");
AddParameter(ParameterType_Choice, "classifier.libsvm.m", "SVM Model Type");
SetParameterDescription("classifier.libsvm.m", "Type of SVM formulation.");
if (this->m_RegressionFlag)
{
AddChoice("classifier.libsvm.m.epssvr", "Epsilon Support Vector Regression");
AddChoice("classifier.libsvm.m.nusvr", "Nu Support Vector Regression");
SetParameterString("classifier.libsvm.m", "epssvr");
}
else
{
AddChoice("classifier.libsvm.m.csvc", "C support vector classification");
AddChoice("classifier.libsvm.m.nusvc", "Nu support vector classification");
AddChoice("classifier.libsvm.m.oneclass", "Distribution estimation (One Class SVM)");
SetParameterString("classifier.libsvm.m", "csvc");
}
AddParameter(ParameterType_Float, "classifier.libsvm.c", "Cost parameter C");
SetParameterFloat("classifier.libsvm.c", 1.0);
SetParameterDescription(
......@@ -48,6 +63,14 @@ namespace Wrapper
AddParameter(ParameterType_Empty, "classifier.libsvm.prob", "Probability estimation");
MandatoryOff("classifier.libsvm.prob");
SetParameterDescription("classifier.libsvm.prob", "Probability estimation flag.");
if (this->m_RegressionFlag)
{
AddParameter(ParameterType_Float, "classifier.libsvm.eps", "Epsilon");
SetParameterFloat("classifier.libsvm.eps", 1e-3);
AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Nu");
SetParameterFloat("classifier.libsvm.nu", 0.5);
}
}
template <class TInputValue, class TOutputValue>
......@@ -91,6 +114,42 @@ namespace Wrapper
libSVMClassifier->SetKernelType(LINEAR);
break;
}
if (this->m_RegressionFlag)
{
switch (GetParameterInt("classifier.libsvm.m"))
{
case 0: // EPSILON_SVR
libSVMClassifier->SetSVMType(EPSILON_SVR);
break;
case 1: // NU_SVR
libSVMClassifier->SetSVMType(NU_SVR);
break;
default:
libSVMClassifier->SetSVMType(EPSILON_SVR);
break;
}
libSVMClassifier->SetEpsilon(GetParameterFloat("classifier.libsvm.eps"));
libSVMClassifier->SetNu(GetParameterFloat("classifier.libsvm.nu"));
}
else
{
switch (GetParameterInt("classifier.libsvm.m"))
{
case 0: // C_SVC
libSVMClassifier->SetSVMType(C_SVC);
break;
case 1: // NU_SVC
libSVMClassifier->SetSVMType(NU_SVC);
break;
case 2: // ONE_CLASS
libSVMClassifier->SetSVMType(ONE_CLASS);
break;
default:
libSVMClassifier->SetSVMType(C_SVC);
break;
}
}
libSVMClassifier->Train();
libSVMClassifier->Save(modelPath);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment