OTB  6.7.0
Orfeo Toolbox
Public Types | Protected Member Functions | Private Member Functions | Private Attributes | 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

enum  {
  KNN_VOTING,
  KNN_MEAN,
  KNN_MEDIAN
}
 
typedef
Superclass::ConfidenceValueType 
ConfidenceValueType
 
typedef itk::SmartPointer
< const Self
ConstPointer
 
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 Self
ConstPointer
 
typedef MLMSampleTraits
< TInputValue >::ValueType 
InputValueType
 
typedef MLMSampleTraits
< TInputValue >::SampleType 
InputSampleType
 
typedef
itk::Statistics::ListSample
< InputSampleType
InputListSampleType
 
typedef MLMTargetTraits
< TTargetValue >::ValueType 
TargetValueType
 
typedef MLMTargetTraits
< TTargetValue >::SampleType 
TargetSampleType
 
typedef
itk::Statistics::ListSample
< TargetSampleType
TargetListSampleType
 
typedef MLMTargetTraits
< double >::ValueType 
ConfidenceValueType
 
typedef MLMTargetTraits
< double >::SampleType 
ConfidenceSampleType
 
typedef
itk::Statistics::ListSample
< ConfidenceSampleType
ConfidenceListSampleType
 
typedef
itk::VariableLengthVector
< double > 
ProbaSampleType
 
typedef
itk::Statistics::ListSample
< ProbaSampleType
ProbaListSampleType
 
- Public Types inherited from itk::Object
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef Object Self
 
typedef LightObject Superclass
 
- Public Types inherited from itk::LightObject
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef LightObject Self
 

Public Member Functions

virtual int GetK ()
 
virtual void SetK (int _arg)
 
virtual int GetDecisionRule ()
 
virtual void SetDecisionRule (int _arg)
 
Classification model file compatibility tests
bool CanReadFile (const std::string &) override
 
bool CanWriteFile (const std::string &) override
 
- Public Member Functions inherited from otb::MachineLearningModel< TInputValue, TTargetValue >
bool HasConfidenceIndex () const
 
bool HasProbaIndex () const
 
 itkGetObjectMacro (ConfidenceListSample, ConfidenceListSampleType)
 
TargetSampleType Predict (const InputSampleType &input, ConfidenceValueType *quality=nullptr, ProbaSampleType *proba=nullptr) const
 
TargetListSampleType::Pointer PredictBatch (const InputListSampleType *input, ConfidenceListSampleType *quality=nullptr, ProbaListSampleType *proba=nullptr) const
 
virtual void SetDimension (unsigned int _arg)
 
virtual unsigned int GetDimension ()
 
virtual void SetInputListSample (InputListSampleType *_arg)
 
 itkGetObjectMacro (InputListSample, InputListSampleType)
 
virtual const InputListSampleTypeGetInputListSample () const
 
 itkGetObjectMacro (TargetListSample, TargetListSampleType)
 
virtual void SetTargetListSample (TargetListSampleType *_arg)
 
virtual bool GetRegressionMode ()
 
void SetRegressionMode (bool flag)
 
- Public Member Functions inherited from itk::Object
unsigned long AddObserver (const EventObject &event, Command *)
 
unsigned long AddObserver (const EventObject &event, Command *) const
 
virtual void DebugOff () const
 
virtual void DebugOn () const
 
CommandGetCommand (unsigned long tag)
 
bool GetDebug () const
 
const MetaDataDictionaryGetMetaDataDictionary () const
 
MetaDataDictionaryGetMetaDataDictionary ()
 
virtual ModifiedTimeType GetMTime () const
 
virtual const std::string & GetObjectName () const
 
virtual const TimeStampGetTimeStamp () const
 
bool HasObserver (const EventObject &event) const
 
void InvokeEvent (const EventObject &)
 
void InvokeEvent (const EventObject &) const
 
virtual void Modified () const
 
virtual void Register () const override
 
void RemoveAllObservers ()
 
void RemoveObserver (unsigned long tag)
 
void SetDebug (bool debugFlag) const
 
void SetMetaDataDictionary (const MetaDataDictionary &rhs)
 
virtual void SetObjectName (std::string _arg)
 
virtual void SetReferenceCount (int) override
 
virtual void UnRegister () const noexceptoverride
 
- Public Member Functions inherited from itk::LightObject
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
 itkCloneMacro (Self)
 
void Print (std::ostream &os, Indent indent=0) const
 

Protected Member Functions

 KNearestNeighborsMachineLearningModel ()
 
 ~KNearestNeighborsMachineLearningModel () override
 
- Protected Member Functions inherited from otb::MachineLearningModel< TInputValue, TTargetValue >
 MachineLearningModel ()
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
 ~MachineLearningModel () override
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
virtual void SetTimeStamp (const TimeStamp &time)
 
virtual ~Object ()
 
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 
 LightObject ()
 
virtual void PrintHeader (std::ostream &os, Indent indent) const
 
virtual void PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 

Private Member Functions

 KNearestNeighborsMachineLearningModel (const Self &)=delete
 
void operator= (const Self &)=delete
 

Private Attributes

int m_DecisionRule
 
int m_K
 
CvKNearest * m_KNearestModel
 
static Pointer New ()
 
virtual ::itk::LightObject::Pointer CreateAnother (void) const
 
virtual const char * GetNameOfClass () const
 
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
 
TargetSampleType DoPredict (const InputSampleType &input, ConfidenceValueType *quality=nullptr, ProbaSampleType *proba=nullptr) const override
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 

Additional Inherited Members

- Static Public Member Functions inherited from itk::Object
static bool GetGlobalWarningDisplay ()
 
static void GlobalWarningDisplayOff ()
 
static void GlobalWarningDisplayOn ()
 
static Pointer New ()
 
static void SetGlobalWarningDisplay (bool flag)
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 
- Protected Attributes inherited from otb::MachineLearningModel< TInputValue, TTargetValue >
bool m_ConfidenceIndex
 
ConfidenceListSampleType::Pointer m_ConfidenceListSample
 
unsigned int m_Dimension
 
InputListSampleType::Pointer m_InputListSample
 
bool m_IsDoPredictBatchMultiThreaded
 
bool m_IsRegressionSupported
 
bool m_ProbaIndex
 
bool m_RegressionMode
 
TargetListSampleType::Pointer m_TargetListSample
 
InputListSampleType::Pointer m_ValidationListSample
 
- Protected Attributes inherited from itk::LightObject
AtomicInt< int > m_ReferenceCount
 

Detailed Description

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

Definition at line 39 of file otbKNearestNeighborsMachineLearningModel.h.

Member Typedef Documentation

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

Definition at line 55 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 47 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 51 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 50 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 49 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 46 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 56 of file otbKNearestNeighborsMachineLearningModel.h.

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

Standard class typedefs.

Definition at line 44 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 45 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 54 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 53 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 52 of file otbKNearestNeighborsMachineLearningModel.h.

Member Enumeration Documentation

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 77 of file otbKNearestNeighborsMachineLearningModel.h.

Constructor & Destructor Documentation

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

Constructor

Definition at line 37 of file otbKNearestNeighborsMachineLearningModel.hxx.

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

Destructor

Definition at line 53 of file otbKNearestNeighborsMachineLearningModel.hxx.

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

Member Function Documentation

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 325 of file otbKNearestNeighborsMachineLearningModel.hxx.

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 341 of file otbKNearestNeighborsMachineLearningModel.hxx.

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

Run-time type information (and related methods).

Reimplemented from itk::Object.

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 110 of file otbKNearestNeighborsMachineLearningModel.hxx.

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

Setters/Getters to the decision rule

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
template<class TInputValue, class TTargetValue>
virtual const char* otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods).

Reimplemented from otb::MachineLearningModel< TInputValue, TTargetValue >.

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 214 of file otbKNearestNeighborsMachineLearningModel.hxx.

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

Run-time type information (and related methods).

template<class TInputValue, class TTargetValue>
void otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::operator= ( const Self )
privatedelete
template<class TInputValue , class TTargetValue >
void otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
overrideprotectedvirtual

PrintSelf method

Reimplemented from itk::Object.

Definition at line 350 of file otbKNearestNeighborsMachineLearningModel.hxx.

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

Setters/Getters to the decision rule

template<class TInputValue, class TTargetValue>
virtual void otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::SetK ( int  _arg)
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
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 64 of file otbKNearestNeighborsMachineLearningModel.hxx.

Member Data Documentation

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

Definition at line 127 of file otbKNearestNeighborsMachineLearningModel.h.

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

Definition at line 125 of file otbKNearestNeighborsMachineLearningModel.h.

template<class TInputValue, class TTargetValue>
CvKNearest* otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >::m_KNearestModel
private

Definition at line 123 of file otbKNearestNeighborsMachineLearningModel.h.


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