OTB  9.0.0
Orfeo Toolbox
Public Types | List of all members
otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue > Class Template Reference

#include <otbKNearestNeighborsMachineLearningModel.h>

+ Inheritance diagram for otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >:
+ Collaboration diagram for otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >:

Public Types

typedef Superclass::ConfidenceValueType ConfidenceValueType
 
typedef itk::SmartPointer< const SelfConstPointer
 
typedef Superclass::InputListSampleType InputListSampleType
 
typedef Superclass::InputSampleType InputSampleType
 
typedef Superclass::InputValueType InputValueType
 
typedef itk::SmartPointer< SelfPointer
 
typedef Superclass::ProbaSampleType ProbaSampleType
 
typedef KNearestNeighborsMachineLearningModel Self
 
typedef MachineLearningModel< TInputValue, TTargetValue > Superclass
 
typedef Superclass::TargetListSampleType TargetListSampleType
 
typedef Superclass::TargetSampleType TargetSampleType
 
typedef Superclass::TargetValueType TargetValueType
 
- Public Types inherited from otb::MachineLearningModel< TInputValue, TTargetValue >
typedef MachineLearningModel Self
 
typedef itk::Object Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 
typedef MLMSampleTraits< TInputValue >::ValueType InputValueType
 
typedef MLMSampleTraits< TInputValue >::SampleType InputSampleType
 
typedef itk::Statistics::ListSample< InputSampleTypeInputListSampleType
 
typedef MLMTargetTraits< TTargetValue >::ValueType TargetValueType
 
typedef MLMTargetTraits< TTargetValue >::SampleType TargetSampleType
 
typedef itk::Statistics::ListSample< TargetSampleTypeTargetListSampleType
 
typedef MLMTargetTraits< double >::ValueType ConfidenceValueType
 
typedef MLMTargetTraits< double >::SampleType ConfidenceSampleType
 
typedef itk::Statistics::ListSample< ConfidenceSampleTypeConfidenceListSampleType
 
typedef itk::VariableLengthVector< double > ProbaSampleType
 
typedef itk::Statistics::ListSample< ProbaSampleTypeProbaListSampleType
 
enum  {
  KNN_VOTING,
  KNN_MEAN,
  KNN_MEDIAN
}
 
static Pointer New ()
 
virtual ::itk::LightObject::Pointer CreateAnother (void) const
 
virtual const char * GetNameOfClass () const
 
virtual int GetK ()
 
virtual void SetK (int _arg)
 
virtual int GetDecisionRule ()
 
virtual void SetDecisionRule (int _arg)
 
void Train () override
 
void Save (const std::string &filename, const std::string &name="") override
 
void Load (const std::string &filename, const std::string &name="") override
 

Classification model file compatibility tests

cv::Ptr< cv::ml::KNearest > m_KNearestModel
 
int m_K
 
int m_DecisionRule
 
bool CanReadFile (const std::string &) override
 
bool CanWriteFile (const std::string &) override
 
 KNearestNeighborsMachineLearningModel ()
 
 ~KNearestNeighborsMachineLearningModel () override=default
 
TargetSampleType DoPredict (const InputSampleType &input, ConfidenceValueType *quality=nullptr, ProbaSampleType *proba=nullptr) const override
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
 KNearestNeighborsMachineLearningModel (const Self &)=delete
 
void operator= (const Self &)=delete
 

Additional Inherited Members

- Public Member Functions inherited from otb::MachineLearningModel< TInputValue, TTargetValue >
virtual const char * GetNameOfClass () const
 
TargetSampleType Predict (const InputSampleType &input, ConfidenceValueType *quality=nullptr, ProbaSampleType *proba=nullptr) const
 
virtual void SetDimension (unsigned int _arg)
 
virtual unsigned int GetDimension ()
 
TargetListSampleType::Pointer PredictBatch (const InputListSampleType *input, ConfidenceListSampleType *quality=nullptr, ProbaListSampleType *proba=nullptr) const
 
bool HasConfidenceIndex () const
 
bool HasProbaIndex () const
 
virtual void SetInputListSample (InputListSampleType *_arg)
 
 itkGetObjectMacro (InputListSample, InputListSampleType)
 
virtual const InputListSampleTypeGetInputListSample () const
 
 itkGetObjectMacro (TargetListSample, TargetListSampleType)
 
 itkGetObjectMacro (ConfidenceListSample, ConfidenceListSampleType)
 
virtual void SetTargetListSample (TargetListSampleType *_arg)
 
virtual bool GetRegressionMode ()
 
void SetRegressionMode (bool flag)
 
- Protected Member Functions inherited from otb::MachineLearningModel< TInputValue, TTargetValue >
 MachineLearningModel ()
 
 ~MachineLearningModel () override=default
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
- Protected Attributes inherited from otb::MachineLearningModel< TInputValue, TTargetValue >
InputListSampleType::Pointer m_InputListSample
 
InputListSampleType::Pointer m_ValidationListSample
 
TargetListSampleType::Pointer m_TargetListSample
 
ConfidenceListSampleType::Pointer m_ConfidenceListSample
 
bool m_RegressionMode
 
bool m_IsRegressionSupported
 
bool m_ConfidenceIndex
 
bool m_ProbaIndex
 
bool m_IsDoPredictBatchMultiThreaded
 
unsigned int m_Dimension
 

Detailed Description

template<class TInputValue, class TTargetValue>
class otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >

Definition at line 35 of file otbKNearestNeighborsMachineLearningModel.h.

Member Typedef Documentation

◆ ConfidenceValueType

template<class TInputValue , class TTargetValue >
typedef Superclass::ConfidenceValueType otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::ConfidenceValueType

Definition at line 50 of file otbKNearestNeighborsMachineLearningModel.h.

◆ ConstPointer

template<class TInputValue , class TTargetValue >
typedef itk::SmartPointer<const Self> otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::ConstPointer

Definition at line 42 of file otbKNearestNeighborsMachineLearningModel.h.

◆ InputListSampleType

template<class TInputValue , class TTargetValue >
typedef Superclass::InputListSampleType otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::InputListSampleType

Definition at line 46 of file otbKNearestNeighborsMachineLearningModel.h.

◆ InputSampleType

template<class TInputValue , class TTargetValue >
typedef Superclass::InputSampleType otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::InputSampleType

Definition at line 45 of file otbKNearestNeighborsMachineLearningModel.h.

◆ InputValueType

template<class TInputValue , class TTargetValue >
typedef Superclass::InputValueType otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::InputValueType

Definition at line 44 of file otbKNearestNeighborsMachineLearningModel.h.

◆ Pointer

template<class TInputValue , class TTargetValue >
typedef itk::SmartPointer<Self> otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::Pointer

Definition at line 41 of file otbKNearestNeighborsMachineLearningModel.h.

◆ ProbaSampleType

template<class TInputValue , class TTargetValue >
typedef Superclass::ProbaSampleType otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::ProbaSampleType

Definition at line 51 of file otbKNearestNeighborsMachineLearningModel.h.

◆ Self

template<class TInputValue , class TTargetValue >
typedef KNearestNeighborsMachineLearningModel otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::Self

Standard class typedefs.

Definition at line 39 of file otbKNearestNeighborsMachineLearningModel.h.

◆ Superclass

template<class TInputValue , class TTargetValue >
typedef MachineLearningModel<TInputValue, TTargetValue> otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::Superclass

Definition at line 40 of file otbKNearestNeighborsMachineLearningModel.h.

◆ TargetListSampleType

template<class TInputValue , class TTargetValue >
typedef Superclass::TargetListSampleType otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::TargetListSampleType

Definition at line 49 of file otbKNearestNeighborsMachineLearningModel.h.

◆ TargetSampleType

template<class TInputValue , class TTargetValue >
typedef Superclass::TargetSampleType otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::TargetSampleType

Definition at line 48 of file otbKNearestNeighborsMachineLearningModel.h.

◆ TargetValueType

template<class TInputValue , class TTargetValue >
typedef Superclass::TargetValueType otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::TargetValueType

Definition at line 47 of file otbKNearestNeighborsMachineLearningModel.h.

Member Enumeration Documentation

◆ anonymous enum

template<class TInputValue , class TTargetValue >
anonymous enum

Decision rule once the KNN are found : [for classification]

  • KNN_VOTING : output value with maximum occurrences (for classification) [for regression]
  • KNN_MEAN : output mean value of neighbors
  • KNN_MEDIAN : output median value of neighbors
Enumerator
KNN_VOTING 
KNN_MEAN 
KNN_MEDIAN 

Definition at line 72 of file otbKNearestNeighborsMachineLearningModel.h.

Constructor & Destructor Documentation

◆ KNearestNeighborsMachineLearningModel() [1/2]

template<class TInputValue , class TTargetValue >
otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::KNearestNeighborsMachineLearningModel
protected

◆ ~KNearestNeighborsMachineLearningModel()

template<class TInputValue , class TTargetValue >
otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::~KNearestNeighborsMachineLearningModel ( )
overrideprotecteddefault

Destructor

◆ KNearestNeighborsMachineLearningModel() [2/2]

template<class TInputValue , class TTargetValue >
otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::KNearestNeighborsMachineLearningModel ( const Self )
privatedelete

Is the input model file readable and compatible with the corresponding classifier ?

Member Function Documentation

◆ CanReadFile()

template<class TInputValue , class TTargetValue >
bool otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::CanReadFile ( const std::string &  file)
overridevirtual

Is the input model file readable and compatible with the corresponding classifier ?

Implements otb::MachineLearningModel< TInputValue, TTargetValue >.

Definition at line 257 of file otbKNearestNeighborsMachineLearningModel.hxx.

◆ CanWriteFile()

template<class TInputValue , class TTargetValue >
bool otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::CanWriteFile ( const std::string &  )
overridevirtual

Is the input model file writable and compatible with the corresponding classifier ?

Implements otb::MachineLearningModel< TInputValue, TTargetValue >.

Definition at line 271 of file otbKNearestNeighborsMachineLearningModel.hxx.

◆ CreateAnother()

template<class TInputValue , class TTargetValue >
virtual::itk::LightObject::Pointer otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::CreateAnother ( void  ) const

Decision rule once the KNN are found : [for classification]

  • KNN_VOTING : output value with maximum occurrences (for classification) [for regression]
  • KNN_MEAN : output mean value of neighbors
  • KNN_MEDIAN : output median value of neighbors

◆ DoPredict()

template<class TInputValue , class TTargetValue >
KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::TargetSampleType otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::DoPredict ( const InputSampleType input,
ConfidenceValueType quality = nullptr,
ProbaSampleType proba = nullptr 
) const
overrideprotected

Predict values using the model

Definition at line 84 of file otbKNearestNeighborsMachineLearningModel.hxx.

◆ GetDecisionRule()

template<class TInputValue , class TTargetValue >
virtual int otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::GetDecisionRule ( )
virtual

Setters/Getters to the decision rule

◆ GetK()

template<class TInputValue , class TTargetValue >
virtual int otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::GetK ( )
virtual

Setters/Getters to the number of neighbors to use Default is 32

See also
http://docs.opencv.org/modules/ml/doc/k_nearest_neighbors.html

◆ GetNameOfClass()

template<class TInputValue , class TTargetValue >
virtual const char* otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::GetNameOfClass ( ) const
virtual

Decision rule once the KNN are found : [for classification]

  • KNN_VOTING : output value with maximum occurrences (for classification) [for regression]
  • KNN_MEAN : output mean value of neighbors
  • KNN_MEDIAN : output median value of neighbors

◆ Load()

template<class TInputValue , class TTargetValue >
void otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::Load ( const std::string &  filename,
const std::string &  name = "" 
)
overridevirtual

Load the model from file

Implements otb::MachineLearningModel< TInputValue, TTargetValue >.

Definition at line 149 of file otbKNearestNeighborsMachineLearningModel.hxx.

◆ New()

template<class TInputValue , class TTargetValue >
static Pointer otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::New ( )
static

Run-time type information (and related methods).

◆ operator=()

template<class TInputValue , class TTargetValue >
void otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::operator= ( const Self )
privatedelete

Is the input model file readable and compatible with the corresponding classifier ?

◆ PrintSelf()

template<class TInputValue , class TTargetValue >
void otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
overrideprotected

PrintSelf method

Definition at line 278 of file otbKNearestNeighborsMachineLearningModel.hxx.

◆ Save()

template<class TInputValue , class TTargetValue >
void otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::Save ( const std::string &  filename,
const std::string &  name = "" 
)
overridevirtual

◆ SetDecisionRule()

template<class TInputValue , class TTargetValue >
virtual void otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::SetDecisionRule ( int  _arg)
virtual

Decision rule once the KNN are found : [for classification]

  • KNN_VOTING : output value with maximum occurrences (for classification) [for regression]
  • KNN_MEAN : output mean value of neighbors
  • KNN_MEDIAN : output median value of neighbors

◆ SetK()

template<class TInputValue , class TTargetValue >
virtual void otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::SetK ( int  _arg)
virtual

Decision rule once the KNN are found : [for classification]

  • KNN_VOTING : output value with maximum occurrences (for classification) [for regression]
  • KNN_MEAN : output mean value of neighbors
  • KNN_MEDIAN : output median value of neighbors

◆ Train()

template<class TInputValue , class TTargetValue >
void otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::Train
overridevirtual

Train the machine learning model

Implements otb::MachineLearningModel< TInputValue, TTargetValue >.

Definition at line 48 of file otbKNearestNeighborsMachineLearningModel.hxx.

Member Data Documentation

◆ m_DecisionRule

template<class TInputValue , class TTargetValue >
int otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::m_DecisionRule
private

Is the input model file readable and compatible with the corresponding classifier ?

Definition at line 124 of file otbKNearestNeighborsMachineLearningModel.h.

◆ m_K

template<class TInputValue , class TTargetValue >
int otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::m_K
private

Is the input model file readable and compatible with the corresponding classifier ?

Definition at line 122 of file otbKNearestNeighborsMachineLearningModel.h.

◆ m_KNearestModel

template<class TInputValue , class TTargetValue >
cv::Ptr<cv::ml::KNearest> otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::m_KNearestModel
private

Is the input model file readable and compatible with the corresponding classifier ?

Definition at line 120 of file otbKNearestNeighborsMachineLearningModel.h.


The documentation for this class was generated from the following files: