OTB  9.0.0
Orfeo Toolbox
otbNormalBayesMachineLearningModel.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 otbNormalBayesMachineLearningModel_h
22 #define otbNormalBayesMachineLearningModel_h
23 
24 #include "otbRequiresOpenCVCheck.h"
25 
26 #include "itkLightObject.h"
27 #include "itkFixedArray.h"
29 
30 #include "otbOpenCVUtils.h"
31 
32 namespace otb
33 {
34 template <class TInputValue, class TTargetValue>
35 class ITK_EXPORT NormalBayesMachineLearningModel : public MachineLearningModel<TInputValue, TTargetValue>
36 {
37 public:
41  typedef itk::SmartPointer<Self> Pointer;
42  typedef itk::SmartPointer<const Self> ConstPointer;
43 
45  typedef typename Superclass::InputSampleType InputSampleType;
50  typedef typename Superclass::ConfidenceValueType ConfidenceValueType;
51  typedef typename Superclass::ProbaSampleType ProbaSampleType;
53  itkNewMacro(Self);
56 
58  void Train() override;
59 
61  void Save(const std::string& filename, const std::string& name = "") override;
62 
64  void Load(const std::string& filename, const std::string& name = "") override;
65 
68 
70  bool CanReadFile(const std::string&) override;
71 
73  bool CanWriteFile(const std::string&) override;
75 
76 protected:
79 
81  ~NormalBayesMachineLearningModel() override = default;
82 
84  TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType* quality = nullptr, ProbaSampleType* proba = nullptr) const override;
85 
87  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
88 
89 private:
90  NormalBayesMachineLearningModel(const Self&) = delete;
91  void operator=(const Self&) = delete;
92  cv::Ptr<cv::ml::NormalBayesClassifier> m_NormalBayesModel;
93 };
94 } // end namespace otb
95 
96 #ifndef OTB_MANUAL_INSTANTIATION
98 #endif
99 
100 #endif
otb::MachineLearningModel::TargetListSampleType
itk::Statistics::ListSample< TargetSampleType > TargetListSampleType
Definition: otbMachineLearningModel.h:92
otbNormalBayesMachineLearningModel.hxx
otb::NormalBayesMachineLearningModel::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbNormalBayesMachineLearningModel.h:41
otb::MachineLearningModel::InputListSampleType
itk::Statistics::ListSample< InputSampleType > InputListSampleType
Definition: otbMachineLearningModel.h:85
otb::NormalBayesMachineLearningModel::Self
NormalBayesMachineLearningModel Self
Definition: otbNormalBayesMachineLearningModel.h:39
otb::MachineLearningModel< TInputValue, TTargetValue >::InputValueType
MLMSampleTraits< TInputValue >::ValueType InputValueType
Definition: otbMachineLearningModel.h:83
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::NormalBayesMachineLearningModel::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbNormalBayesMachineLearningModel.h:42
otb::NormalBayesMachineLearningModel::m_NormalBayesModel
cv::Ptr< cv::ml::NormalBayesClassifier > m_NormalBayesModel
Definition: otbNormalBayesMachineLearningModel.h:92
otb::NormalBayesMachineLearningModel::InputListSampleType
Superclass::InputListSampleType InputListSampleType
Definition: otbNormalBayesMachineLearningModel.h:46
otbMachineLearningModel.h
otb::NormalBayesMachineLearningModel::Superclass
MachineLearningModel< TInputValue, TTargetValue > Superclass
Definition: otbNormalBayesMachineLearningModel.h:40
otb::NormalBayesMachineLearningModel
Definition: otbNormalBayesMachineLearningModel.h:35
otb::NormalBayesMachineLearningModel::InputValueType
Superclass::InputValueType InputValueType
Definition: otbNormalBayesMachineLearningModel.h:44
otb::NormalBayesMachineLearningModel::ConfidenceValueType
Superclass::ConfidenceValueType ConfidenceValueType
Definition: otbNormalBayesMachineLearningModel.h:50
otb::MachineLearningModel
MachineLearningModel is the base class for all classifier objects (SVM, KNN, Random Forests,...
Definition: otbMachineLearningModel.h:70
otb::NormalBayesMachineLearningModel::ProbaSampleType
Superclass::ProbaSampleType ProbaSampleType
Definition: otbNormalBayesMachineLearningModel.h:51
otbOpenCVUtils.h
otb::MachineLearningModel< TInputValue, TTargetValue >::TargetValueType
MLMTargetTraits< TTargetValue >::ValueType TargetValueType
Definition: otbMachineLearningModel.h:90
otb::NormalBayesMachineLearningModel::TargetValueType
Superclass::TargetValueType TargetValueType
Definition: otbNormalBayesMachineLearningModel.h:47
otb::NormalBayesMachineLearningModel::InputSampleType
Superclass::InputSampleType InputSampleType
Definition: otbNormalBayesMachineLearningModel.h:45
otb::NormalBayesMachineLearningModel::TargetListSampleType
Superclass::TargetListSampleType TargetListSampleType
Definition: otbNormalBayesMachineLearningModel.h:49
otbRequiresOpenCVCheck.h
otb::MachineLearningModel::TargetSampleType
MLMTargetTraits< TTargetValue >::SampleType TargetSampleType
Definition: otbMachineLearningModel.h:91
otb::NormalBayesMachineLearningModel::TargetSampleType
Superclass::TargetSampleType TargetSampleType
Definition: otbNormalBayesMachineLearningModel.h:48