OTB  9.0.0
Orfeo Toolbox
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
otb::DecisionTree< AttributeValueType, LabelType > Class Template Reference

#include <otbDecisionTree.h>

+ Inheritance diagram for otb::DecisionTree< AttributeValueType, LabelType >:
+ Collaboration diagram for otb::DecisionTree< AttributeValueType, LabelType >:

Public Types

typedef itk::SmartPointer< const SelfConstPointer
 
enum  DecisionTreeTestType {
  MIN,
  LT = MIN,
  LE,
  EQ,
  GE,
  GT,
  MAX = GT
}
 
typedef std::vector< AttributeValueType > ExampleType
 
typedef std::pair< AttributeValueType, DecisionTreeTestTypeKeyType
 
typedef std::map< KeyType, LabelType > LabelMapType
 
typedef itk::SmartPointer< SelfPointer
 
typedef DecisionTree Self
 
typedef itk::DataObject Superclass
 
typedef std::map< KeyType, PointerTreeMapType
 

Public Member Functions

void AddBranch (AttributeValueType attr, DecisionTreeTestType testType, LabelType label)
 
void AddBranch (AttributeValueType attr, DecisionTreeTestType testType, Pointer branch)
 
void AddBranch (AttributeValueType attr, LabelType label)
 
void AddBranch (AttributeValueType attr, Pointer branch)
 
virtual ::itk::LightObject::Pointer CreateAnother (void) const
 
LabelType Decide (const ExampleType &example)
 
virtual unsigned int GetAttribute ()
 
virtual const char * GetNameOfClass () const
 
virtual void SetAttribute (unsigned int _arg)
 

Static Public Member Functions

static Pointer New ()
 

Protected Member Functions

 DecisionTree ()
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 
 ~DecisionTree () override
 

Private Member Functions

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

Private Attributes

unsigned int m_Attribute
 
bool m_IsFinal
 
LabelType m_Label
 
LabelMapType m_LabelMap
 
TreeMapTypem_TreeMap
 

Detailed Description

template<class AttributeValueType, class LabelType>
class otb::DecisionTree< AttributeValueType, LabelType >

Models a decision tree.

A decision tree holds an attribute that is being tested and 2 maps (STL): one for subtrees and another for labels (for the case where there are no subtrees). These maps as keys a pair (STL) which holds the value of the attribute being tested as well as the type of test (LT, LE, EQ, GE, GT).

In order to build a tree, one uses the method AddBranch. There are 2 versions of this method: one for adding a subtree, and another for adding labels in the case of leaf nodes. Each of these versions has a syntactic sugar version for the case of EQ test.

This implementation does not use different classes for terminal and non terminal nodes for simplicity and follows the implementation suggested by P. Norvig in the python version of the AIMA code which is available at http://aima-python.googlecode.com/svn/trunk/learning.py

In the case of several terminal nodes being eligible, the first is returned.

See also
DecisionTreeClassifier
DecisionTreeEstimator

Definition at line 61 of file otbDecisionTree.h.

Member Typedef Documentation

◆ ConstPointer

template<class AttributeValueType , class LabelType >
typedef itk::SmartPointer<const Self> otb::DecisionTree< AttributeValueType, LabelType >::ConstPointer

Definition at line 78 of file otbDecisionTree.h.

◆ ExampleType

template<class AttributeValueType , class LabelType >
typedef std::vector<AttributeValueType> otb::DecisionTree< AttributeValueType, LabelType >::ExampleType

Definition at line 89 of file otbDecisionTree.h.

◆ KeyType

template<class AttributeValueType , class LabelType >
typedef std::pair<AttributeValueType, DecisionTreeTestType> otb::DecisionTree< AttributeValueType, LabelType >::KeyType

Definition at line 84 of file otbDecisionTree.h.

◆ LabelMapType

template<class AttributeValueType , class LabelType >
typedef std::map<KeyType, LabelType> otb::DecisionTree< AttributeValueType, LabelType >::LabelMapType

Definition at line 88 of file otbDecisionTree.h.

◆ Pointer

template<class AttributeValueType , class LabelType >
typedef itk::SmartPointer<Self> otb::DecisionTree< AttributeValueType, LabelType >::Pointer

Definition at line 77 of file otbDecisionTree.h.

◆ Self

template<class AttributeValueType , class LabelType >
typedef DecisionTree otb::DecisionTree< AttributeValueType, LabelType >::Self

Standard typedefs

Definition at line 75 of file otbDecisionTree.h.

◆ Superclass

template<class AttributeValueType , class LabelType >
typedef itk::DataObject otb::DecisionTree< AttributeValueType, LabelType >::Superclass

Definition at line 76 of file otbDecisionTree.h.

◆ TreeMapType

template<class AttributeValueType , class LabelType >
typedef std::map<KeyType, Pointer> otb::DecisionTree< AttributeValueType, LabelType >::TreeMapType

Definition at line 87 of file otbDecisionTree.h.

Member Enumeration Documentation

◆ DecisionTreeTestType

template<class AttributeValueType , class LabelType >
enum otb::DecisionTree::DecisionTreeTestType
Enumerator
MIN 
LT 
LE 
EQ 
GE 
GT 
MAX 

Definition at line 64 of file otbDecisionTree.h.

Constructor & Destructor Documentation

◆ DecisionTree() [1/2]

template<class AttributeValueType , class LabelType >
otb::DecisionTree< AttributeValueType, LabelType >::DecisionTree
protected

Constructor

Definition at line 34 of file otbDecisionTree.hxx.

◆ ~DecisionTree()

template<class AttributeValueType , class LabelType >
otb::DecisionTree< AttributeValueType, LabelType >::~DecisionTree
overrideprotected

Destructor

Definition at line 45 of file otbDecisionTree.hxx.

◆ DecisionTree() [2/2]

template<class AttributeValueType , class LabelType >
otb::DecisionTree< AttributeValueType, LabelType >::DecisionTree ( const Self )
privatedelete

Member Function Documentation

◆ AddBranch() [1/4]

template<class AttributeValueType , class LabelType >
void otb::DecisionTree< AttributeValueType, LabelType >::AddBranch ( AttributeValueType  attr,
DecisionTreeTestType  testType,
LabelType  label 
)

Add a leaf node on the tested attribute

Definition at line 67 of file otbDecisionTree.hxx.

◆ AddBranch() [2/4]

template<class AttributeValueType , class LabelType >
void otb::DecisionTree< AttributeValueType, LabelType >::AddBranch ( AttributeValueType  attr,
DecisionTreeTestType  testType,
Pointer  branch 
)

Add a subtree on the tested attribute

Definition at line 51 of file otbDecisionTree.hxx.

◆ AddBranch() [3/4]

template<class AttributeValueType , class LabelType >
void otb::DecisionTree< AttributeValueType, LabelType >::AddBranch ( AttributeValueType  attr,
LabelType  label 
)

Add a leaf node on the tested attribute - syntactic sugar for the EQ case

Definition at line 75 of file otbDecisionTree.hxx.

◆ AddBranch() [4/4]

template<class AttributeValueType , class LabelType >
void otb::DecisionTree< AttributeValueType, LabelType >::AddBranch ( AttributeValueType  attr,
Pointer  branch 
)

Add a subtree on the tested attribute - syntactic sugar for the EQ case

Definition at line 59 of file otbDecisionTree.hxx.

◆ CreateAnother()

template<class AttributeValueType , class LabelType >
virtual::itk::LightObject::Pointer otb::DecisionTree< AttributeValueType, LabelType >::CreateAnother ( void  ) const

◆ Decide()

template<class AttributeValueType , class LabelType >
LabelType otb::DecisionTree< AttributeValueType, LabelType >::Decide ( const ExampleType example)

Definition at line 83 of file otbDecisionTree.hxx.

References otbMsgDevMacro.

◆ GetAttribute()

template<class AttributeValueType , class LabelType >
virtual unsigned int otb::DecisionTree< AttributeValueType, LabelType >::GetAttribute ( )
virtual

◆ GetNameOfClass()

template<class AttributeValueType , class LabelType >
virtual const char* otb::DecisionTree< AttributeValueType, LabelType >::GetNameOfClass ( ) const
virtual

Runtime information macro

◆ New()

template<class AttributeValueType , class LabelType >
static Pointer otb::DecisionTree< AttributeValueType, LabelType >::New ( )
static

Creation through object factory macro

◆ operator=()

template<class AttributeValueType , class LabelType >
void otb::DecisionTree< AttributeValueType, LabelType >::operator= ( const Self )
privatedelete

◆ PrintSelf()

template<class AttributeValueType , class LabelType >
void otb::DecisionTree< AttributeValueType, LabelType >::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
overrideprotected

Output information redefinition PrintSelf method

PrintSelf method

Definition at line 209 of file otbDecisionTree.hxx.

◆ SetAttribute()

template<class AttributeValueType , class LabelType >
virtual void otb::DecisionTree< AttributeValueType, LabelType >::SetAttribute ( unsigned int  _arg)
virtual

Member Data Documentation

◆ m_Attribute

template<class AttributeValueType , class LabelType >
unsigned int otb::DecisionTree< AttributeValueType, LabelType >::m_Attribute
private

The attribute number (in the vector) being tested

Definition at line 133 of file otbDecisionTree.h.

◆ m_IsFinal

template<class AttributeValueType , class LabelType >
bool otb::DecisionTree< AttributeValueType, LabelType >::m_IsFinal
private

Is the tree a final node?

Definition at line 136 of file otbDecisionTree.h.

◆ m_Label

template<class AttributeValueType , class LabelType >
LabelType otb::DecisionTree< AttributeValueType, LabelType >::m_Label
private

Definition at line 138 of file otbDecisionTree.h.

◆ m_LabelMap

template<class AttributeValueType , class LabelType >
LabelMapType otb::DecisionTree< AttributeValueType, LabelType >::m_LabelMap
private

Map holding the labels if final node

Definition at line 130 of file otbDecisionTree.h.

◆ m_TreeMap

template<class AttributeValueType , class LabelType >
TreeMapType* otb::DecisionTree< AttributeValueType, LabelType >::m_TreeMap
private

Map holding the subtrees

Definition at line 127 of file otbDecisionTree.h.


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