OTB  5.9.0
Orfeo Toolbox
otbSVMCrossValidationCostFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef otbSVMCrossValidationCostFunction_h
19 #define otbSVMCrossValidationCostFunction_h
20 
21 #include "otbSVMModel.h"
23 
24 namespace otb
25 {
26 
50 template <class TModel>
53 {
54 public:
60 
62  itkNewMacro(Self);
63 
65  typedef TModel SVMModelType;
66  typedef typename SVMModelType::Pointer SVMModelPointer;
67 
69  typedef typename Superclass::MeasureType MeasurementType;
71  typedef typename Superclass::ParametersValueType ParametersValueType;
72  typedef typename Superclass::DerivativeType DerivativeType;
73 
75  itkSetObjectMacro(Model, SVMModelType);
76  itkGetObjectMacro(Model, SVMModelType);
78 
80  itkSetMacro(NumberOfCrossValidationFolders, unsigned int);
81  itkGetMacro(NumberOfCrossValidationFolders, unsigned int);
83 
85  itkSetMacro(DerivativeStep, ParametersValueType);
86  itkGetMacro(DerivativeStep, ParametersValueType);
88 
90  MeasureType GetValue(const ParametersType& parameters) const ITK_OVERRIDE;
91 
93  void GetDerivative(const ParametersType& parameters, DerivativeType& derivative) const ITK_OVERRIDE;
94 
96  unsigned int GetNumberOfParameters(void) const ITK_OVERRIDE;
97 
98 protected:
102  ~SVMCrossValidationCostFunction() ITK_OVERRIDE;
103 
106  virtual void UpdateParameters(struct svm_parameter& svm_parameters, const ParametersType& parameters) const;
107 
108 private:
109  SVMCrossValidationCostFunction(const Self &); //purposely not implemented
110  void operator =(const Self&); //purposely not implemented
111 
114 
116  unsigned int m_NumberOfCrossValidationFolders;
117 
119  ParametersValueType m_DerivativeStep;
120 
121 }; // class SVMCrossValidationCostFunction
122 
123 } // namespace otb
124 
125 #ifndef OTB_MANUAL_INSTANTIATION
127 #endif
128 
129 #endif
Superclass::ParametersValueType ParametersValueType
This function returns the cross validation accuracy of a SVM model.
itk::Array< double > ParametersType
Definition: mvdTypes.h:129
TInternalComputationValueType ParametersValueType