Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Cabieces
otb
Commits
a78e2e13
Commit
a78e2e13
authored
9 years ago
by
Guillaume Pasero
Browse files
Options
Downloads
Patches
Plain Diff
ENH: expose usefull parameter for LibSVM regression
parent
95a5a18a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Modules/Applications/AppClassification/include/otbTrainLibSVM.txx
+59
-0
59 additions, 0 deletions
...Applications/AppClassification/include/otbTrainLibSVM.txx
with
59 additions
and
0 deletions
Modules/Applications/AppClassification/include/otbTrainLibSVM.txx
+
59
−
0
View file @
a78e2e13
...
...
@@ -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);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment