21 #ifndef otbSharkRandomForestsMachineLearningModel_h
22 #define otbSharkRandomForestsMachineLearningModel_h
24 #include "itkLightObject.h"
28 #define BOOST_BIND_GLOBAL_PLACEHOLDERS
30 #if defined(__GNUC__) || defined(__clang__)
31 #pragma GCC diagnostic push
33 #if (defined (__GNUC__) && (__GNUC__ >= 9)) || (defined (__clang__) && (__clang_major__ >= 10))
34 #pragma GCC diagnostic ignored "-Wdeprecated-copy"
36 #pragma GCC diagnostic ignored "-Wshadow"
37 #pragma GCC diagnostic ignored "-Wunused-parameter"
38 #pragma GCC diagnostic ignored "-Woverloaded-virtual"
39 #pragma GCC diagnostic ignored "-Wignored-qualifiers"
40 #pragma GCC diagnostic ignored "-Wsign-compare"
41 #pragma GCC diagnostic ignored "-Wcast-align"
42 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
43 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
44 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
45 #if defined(__clang__)
46 #pragma clang diagnostic ignored "-Wheader-guard"
47 #pragma clang diagnostic ignored "-Wexpansion-to-defined"
49 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
52 #include <shark/Models/Classifier.h>
53 #include "otb_shark.h"
54 #include "shark/Algorithms/Trainers/RFTrainer.h"
55 #if defined(__GNUC__) || defined(__clang__)
56 #pragma GCC diagnostic pop
76 template <
class TInputValue,
class TTargetValue>
103 virtual void Train()
override;
106 virtual void Save(
const std::string& filename,
const std::string& name =
"")
override;
109 virtual void Load(
const std::string& filename,
const std::string& name =
"")
override;
115 virtual bool CanReadFile(
const std::string&)
override;
118 virtual bool CanWriteFile(
const std::string&)
override;
122 itkGetMacro(NumberOfTrees,
unsigned int);
125 itkSetMacro(NumberOfTrees,
unsigned int);
128 itkGetMacro(MTry,
unsigned int);
131 itkSetMacro(MTry,
unsigned int);
136 itkGetMacro(NodeSize,
unsigned int);
141 itkSetMacro(NodeSize,
unsigned int);
146 itkGetMacro(OobRatio,
float);
151 itkSetMacro(OobRatio,
float);
154 itkGetMacro(ComputeMargin,
bool);
157 itkSetMacro(ComputeMargin,
bool);
160 itkGetMacro(NormalizeClassLabels,
bool);
161 itkSetMacro(NormalizeClassLabels,
bool);
178 void PrintSelf(std::ostream& os, itk::Indent indent)
const override;
182 void operator=(
const Self&) =
delete;
196 ConfidenceValueType ComputeConfidence(shark::RealVector& probas,
bool computeMargin)
const;
200 #ifndef OTB_MANUAL_INSTANTIATION