Orfeo ToolBox  4.2
Orfeo ToolBox is not a black box
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 
48 template <class TModel>
51 {
52 public:
58 
60  itkNewMacro(Self);
61 
63  typedef TModel SVMModelType;
64  typedef typename SVMModelType::Pointer SVMModelPointer;
65 
67  typedef typename Superclass::MeasureType MeasurementType;
68  typedef typename Superclass::ParametersType ParametersType;
69  typedef typename Superclass::ParametersValueType ParametersValueType;
70  typedef typename Superclass::DerivativeType DerivativeType;
71 
73  itkSetObjectMacro(Model, SVMModelType);
74  itkGetObjectMacro(Model, SVMModelType);
75 
77  itkSetMacro(NumberOfCrossValidationFolders, unsigned int);
78  itkGetMacro(NumberOfCrossValidationFolders, unsigned int);
79 
81  itkSetMacro(DerivativeStep, ParametersValueType);
82  itkGetMacro(DerivativeStep, ParametersValueType);
83 
85  virtual MeasureType GetValue(const ParametersType& parameters) const;
86 
88  virtual void GetDerivative(const ParametersType& parameters, DerivativeType& derivative) const;
89 
91  virtual unsigned int GetNumberOfParameters(void) const;
92 
93 protected:
98 
101  virtual void UpdateParameters(struct svm_parameter& svm_parameters, const ParametersType& parameters) const;
102 
103 private:
104  SVMCrossValidationCostFunction(const Self &); //purposely not implemented
105  void operator =(const Self&); //purposely not implemented
106 
109 
112 
115 
116 }; // class SVMCrossValidationCostFunction
117 
118 } // namespace otb
119 
120 #ifndef OTB_MANUAL_INSTANTIATION
122 #endif
123 
124 #endif
Superclass::ParametersValueType ParametersValueType
This function returns the cross validation accuracy of a SVM model.