From 27f02b66c454303fb151dd3db0af74055eca41f6 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@orfeo-toolbox.org>
Date: Tue, 21 Oct 2014 16:14:23 +0200
Subject: [PATCH] ENH: Giving access to probability estimates mode in
 libSVMMachineLearningModel (patch kindly contributed by Adrien Gressin)

---
 Code/Learning/otbLibSVMMachineLearningModel.h   | 4 ++++
 Code/Learning/otbLibSVMMachineLearningModel.txx | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/Code/Learning/otbLibSVMMachineLearningModel.h b/Code/Learning/otbLibSVMMachineLearningModel.h
index 410840db68..914542b684 100644
--- a/Code/Learning/otbLibSVMMachineLearningModel.h
+++ b/Code/Learning/otbLibSVMMachineLearningModel.h
@@ -96,6 +96,9 @@ public:
 
   itkGetMacro(ParameterOptimization, bool);
   itkSetMacro(ParameterOptimization, bool);
+ 
+  itkGetMacro(DoProbabilityEstimates, bool);
+  itkSetMacro(DoProbabilityEstimates, bool);
 
   // itkGetMacro(Epsilon, int);
   // itkSetMacro(Epsilon, int);
@@ -117,6 +120,7 @@ private:
   int m_KernelType;
   float m_C;
   bool m_ParameterOptimization;
+  bool m_DoProbabilityEstimates;
   typename SVMEstimatorType::Pointer m_SVMestimator;
 };
 } // end namespace otb
diff --git a/Code/Learning/otbLibSVMMachineLearningModel.txx b/Code/Learning/otbLibSVMMachineLearningModel.txx
index 131db547b7..bbdbc02a0e 100644
--- a/Code/Learning/otbLibSVMMachineLearningModel.txx
+++ b/Code/Learning/otbLibSVMMachineLearningModel.txx
@@ -39,6 +39,7 @@ LibSVMMachineLearningModel<TInputValue,TOutputValue>
   m_C = 1.0;
   // m_Epsilon = 1e-6;
   m_ParameterOptimization = false;
+  m_DoProbabilityEstimates = false;
   m_SVMestimator = SVMEstimatorType::New();
 }
 
@@ -67,6 +68,7 @@ LibSVMMachineLearningModel<TInputValue,TOutputValue>
   m_SVMestimator->SetC(m_C);
   m_SVMestimator->SetKernelType(m_KernelType);
   m_SVMestimator->SetParametersOptimization(m_ParameterOptimization);
+  m_SVMestimator->DoProbabilityEstimates(m_DoProbabilityEstimates);
 
   m_SVMestimator->SetInputSampleList(this->GetInputListSample());
   m_SVMestimator->SetTrainingSampleList(this->GetTargetListSample());
-- 
GitLab