20 #ifndef otbSharkKMeansMachineLearningModel_h
21 #define otbSharkKMeansMachineLearningModel_h
25 #include "itkLightObject.h"
29 #define BOOST_BIND_GLOBAL_PLACEHOLDERS
31 #if defined(__GNUC__) || defined(__clang__)
32 #pragma GCC diagnostic push
34 #if (defined (__GNUC__) && (__GNUC__ >= 9)) || (defined (__clang__) && (__clang_major__ >= 10))
35 #pragma GCC diagnostic ignored "-Wdeprecated-copy"
38 #pragma GCC diagnostic ignored "-Wshadow"
39 #pragma GCC diagnostic ignored "-Wunused-parameter"
40 #pragma GCC diagnostic ignored "-Woverloaded-virtual"
41 #pragma GCC diagnostic ignored "-Wignored-qualifiers"
42 #pragma GCC diagnostic ignored "-Wsign-compare"
43 #pragma GCC diagnostic ignored "-Wcast-align"
44 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
45 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
46 #if defined(__clang__)
47 #pragma clang diagnostic ignored "-Wheader-guard"
48 #pragma clang diagnostic ignored "-Wexpansion-to-defined"
50 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
54 #include "otb_shark.h"
55 #include "shark/Models/Clustering/HardClusteringModel.h"
56 #include "shark/Models/Clustering/SoftClusteringModel.h"
57 #include "shark/Models/Clustering/Centroids.h"
58 #include "shark/Models/Clustering/ClusteringModel.h"
59 #include "shark/Algorithms/KMeans.h"
60 #include "shark/Models/Normalizer.h"
62 #if defined(__GNUC__) || defined(__clang__)
63 #pragma GCC diagnostic pop
81 template <
class TInputValue,
class TTargetValue>
111 virtual void Train()
override;
114 virtual void Save(
const std::string& filename,
const std::string& name =
"")
override;
117 virtual void Load(
const std::string& filename,
const std::string& name =
"")
override;
123 virtual bool CanReadFile(
const std::string&)
override;
126 virtual bool CanWriteFile(
const std::string&)
override;
130 itkGetMacro(MaximumNumberOfIterations,
unsigned);
133 itkSetMacro(MaximumNumberOfIterations,
unsigned);
136 itkGetMacro(K,
unsigned);
139 itkSetMacro(K,
unsigned);
144 m_Centroids.setCentroids(data);
149 void ExportCentroids(
const std::string& filename);
159 virtual TargetSampleType DoPredict(
const InputSampleType& input, ConfidenceValueType* quality =
nullptr, ProbaSampleType* proba =
nullptr)
const override;
161 virtual void DoPredictBatch(
const InputListSampleType*,
const unsigned int& startIndex,
const unsigned int& size, TargetListSampleType*,
162 ConfidenceListSampleType* =
nullptr, ProbaListSampleType* =
nullptr)
const override;
165 void PrintSelf(std::ostream& os, itk::Indent indent)
const override;
169 void operator=(
const Self&) =
delete;
184 #ifndef OTB_MANUAL_INSTANTIATION