diff --git a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h index 700a58eacd3560340853b9d0893a0f64d2a6001c..d42e7481948d9b6a8f253604ddf9e7b1a97e206f 100644 --- a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h +++ b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.h @@ -125,10 +125,6 @@ public: /** Set the number of class for the kMeans algorithm.*/ itkSetMacro( K, unsigned ); - /** If true, normalized input data sample list */ - itkGetMacro( Normalized, bool ); - itkSetMacro( Normalized, bool ); - /** Initialize the centroids for the kmeans algorithm */ void SetCentroidsFromData(const shark::Data<shark::RealVector> & data) { @@ -150,9 +146,6 @@ protected: virtual void DoPredictBatch(const InputListSampleType *, const unsigned int &startIndex, const unsigned int &size, TargetListSampleType *, ConfidenceListSampleType * = nullptr, ProbaListSampleType * = nullptr) const override; - template<typename DataType> - DataType NormalizeData(const DataType &data) const; - template<typename DataType> shark::Normalizer<> TrainNormalizer(const DataType &data) const; @@ -164,7 +157,6 @@ private: void operator=(const Self &) = delete; // Parameters set by the user - bool m_Normalized; unsigned int m_K; unsigned int m_MaximumNumberOfIterations; bool m_CanRead; diff --git a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.hxx b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.hxx index 1d27ce519c63c86216167fa10e3df2cc79625eec..ff95c9501a271cbbdd51b63134428f8b00302ea6 100644 --- a/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.hxx +++ b/Modules/Learning/Unsupervised/include/otbSharkKMeansMachineLearningModel.hxx @@ -52,7 +52,7 @@ namespace otb template<class TInputValue, class TOutputValue> SharkKMeansMachineLearningModel<TInputValue, TOutputValue> ::SharkKMeansMachineLearningModel() : - m_Normalized( false ), m_K(2), m_MaximumNumberOfIterations( 10 ) + m_K(2), m_MaximumNumberOfIterations( 10 ) { // Default set HardClusteringModel this->m_ConfidenceIndex = true; @@ -77,30 +77,11 @@ SharkKMeansMachineLearningModel<TInputValue, TOutputValue> otb::Shark::ListSampleToSharkVector( this->GetInputListSample(), vector_data ); shark::Data<shark::RealVector> data = shark::createDataFromRange( vector_data ); - // Normalized input value if necessary - if( m_Normalized ) - { - auto normalizer = TrainNormalizer(data); - data = normalizer(data); - } - // Use a Hard Clustering Model for classification shark::kMeans( data, m_K, m_Centroids, m_MaximumNumberOfIterations ); m_ClusteringModel = boost::make_shared<ClusteringModelType>( &m_Centroids ); } -template<class TInputValue, class TOutputValue> -template<typename DataType> -DataType -SharkKMeansMachineLearningModel<TInputValue, TOutputValue> -::NormalizeData(const DataType &data) const -{ - shark::Normalizer<> normalizer; - shark::NormalizeComponentsUnitVariance<> normalizingTrainer( true );//zero mean - normalizingTrainer.train( normalizer, data ); - return normalizer( data ); -} - template<class TInputValue, class TOutputValue> template<typename DataType> shark::Normalizer<>