From 316cd8e0c85ba0300d4807ba0bd68aca39293ac6 Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau Date: Fri, 21 Jul 2017 11:02:08 +0200 Subject: [PATCH] Bug fixed. We might want to check the behavior of the nu classification as there is a lot of value that are not acceptable. Either it is the model then it's okay or it's a method that does a strange manipulation changing its value. --- .../include/otbTrainLibSVM.txx | 23 +++++++++++++------ .../include/otbLibSVMMachineLearningModel.h | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx index c380f56de1..82d5bd8410 100644 --- a/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx +++ b/Modules/Applications/AppClassification/include/otbTrainLibSVM.txx @@ -97,6 +97,12 @@ namespace Wrapper SetParameterDescription("classifier.libsvm.c", "SVM models have a cost parameter C (1 by default) to control the " "trade-off between training errors and forcing rigid margins."); + + AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Cost parameter Nu"); + SetParameterFloat("classifier.libsvm.nu",0.5, false); + SetParameterDescription("classifier.libsvm.nu", + "Cost parameter Nu, in the range 0..1, the larger the value, " + "the smoother the decision."); // It seems that it miss a nu parameter for the nu-SVM use. AddParameter(ParameterType_Empty, "classifier.libsvm.opt", "Parameters optimization"); @@ -111,12 +117,14 @@ namespace Wrapper AddParameter(ParameterType_Float, "classifier.libsvm.eps", "Epsilon"); SetParameterFloat("classifier.libsvm.eps",1e-3, false); SetParameterDescription("classifier.libsvm.eps", - "Parameter for the epsilon regression mode."); - AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Nu"); - SetParameterFloat("classifier.libsvm.nu",0.5, false); - SetParameterDescription("classifier.libsvm.nu", - "Cost parameter Nu, in the range 0..1, the larger the value, " - "the smoother the decision."); + "The distance between feature vectors from the training set and " + "the fitting hyper-plane must be less than Epsilon. For outliers" + "the penalty mutliplier is set by C."); + // AddParameter(ParameterType_Float, "classifier.libsvm.nu", "Nu"); + // SetParameterFloat("classifier.libsvm.nu",0.5, false); + // SetParameterDescription("classifier.libsvm.nu", + // "Cost parameter Nu, in the range 0..1, the larger the value, " + // "the smoother the decision."); } } @@ -142,6 +150,7 @@ namespace Wrapper { libSVMClassifier->SetDoProbabilityEstimates(true); } + libSVMClassifier->SetNu(GetParameterFloat("classifier.libsvm.nu")); libSVMClassifier->SetC(GetParameterFloat("classifier.libsvm.c")); switch (GetParameterInt("classifier.libsvm.k")) @@ -177,7 +186,6 @@ namespace Wrapper break; } libSVMClassifier->SetEpsilon(GetParameterFloat("classifier.libsvm.eps")); - libSVMClassifier->SetNu(GetParameterFloat("classifier.libsvm.nu")); } else { @@ -197,6 +205,7 @@ namespace Wrapper break; } } + libSVMClassifier->Train(); libSVMClassifier->Save(modelPath); diff --git a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h index a8baa08e58..329722af5a 100644 --- a/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h +++ b/Modules/Learning/Supervised/include/otbLibSVMMachineLearningModel.h @@ -141,7 +141,7 @@ public: return m_Parameters.coef0; } - /** Set the C parameter for the training for C_SVC, EPSILON_SVR and NU_SVR */ + /** Set the C parameter for the training for C_SVC, EPSILON_SVR and C_SVR */ otbSetSVMParameterMacro(C,C,double) /** Get the C parameter for the training for C_SVC, EPSILON_SVR and NU_SVR */ -- GitLab