OTB  10.0.0
Orfeo Toolbox
otbSVMCrossValidationCostFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbSVMCrossValidationCostFunction_h
22 #define otbSVMCrossValidationCostFunction_h
23 
24 #include "itkSingleValuedCostFunction.h"
25 
26 namespace otb
27 {
28 
52 template <class TModel>
53 class ITK_EXPORT SVMCrossValidationCostFunction : public itk::SingleValuedCostFunction
54 {
55 public:
58  typedef itk::SingleValuedCostFunction Superclass;
59  typedef itk::SmartPointer<Self> Pointer;
60  typedef itk::SmartPointer<const Self> ConstPointer;
61 
63  itkNewMacro(Self);
64 
66  typedef TModel SVMModelType;
67  typedef typename SVMModelType::Pointer SVMModelPointer;
68 
70  typedef typename Superclass::MeasureType MeasurementType;
71  typedef typename Superclass::ParametersType ParametersType;
72  typedef typename Superclass::ParametersValueType ParametersValueType;
73  typedef typename Superclass::DerivativeType DerivativeType;
74 
76  itkSetObjectMacro(Model, SVMModelType);
79 
81  itkSetMacro(DerivativeStep, ParametersValueType);
82  itkGetMacro(DerivativeStep, ParametersValueType);
84 
86  MeasureType GetValue(const ParametersType& parameters) const override;
87 
89  void GetDerivative(const ParametersType& parameters, DerivativeType& derivative) const override;
90 
92  unsigned int GetNumberOfParameters(void) const override;
93 
94 protected:
99 
102  void UpdateParameters(const ParametersType& parameters) const;
103 
104 private:
106  void operator=(const Self&) = delete;
107 
110 
113 
114 }; // class SVMCrossValidationCostFunction
115 
116 } // namespace otb
117 
118 #ifndef OTB_MANUAL_INSTANTIATION
120 #endif
121 
122 #endif
This function returns the cross validation accuracy of a SVM model.
void operator=(const Self &)=delete
Superclass::ParametersValueType ParametersValueType
itkGetObjectMacro(Model, SVMModelType)
SVMCrossValidationCostFunction(const Self &)=delete
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.