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

#include <otbDecisionTreeMachineLearningModel.h>

+ Inheritance diagram for otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >:
+ Collaboration diagram for otb::DecisionTreeMachineLearningModel< 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 DecisionTreeMachineLearningModel 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
 
static Pointer New ()
 
virtual ::itk::LightObject::Pointer CreateAnother (void) const
 
virtual const char * GetNameOfClass () const
 
virtual int GetMaxDepth ()
 
virtual void SetMaxDepth (int _arg)
 
virtual int GetMinSampleCount ()
 
virtual void SetMinSampleCount (int _arg)
 
virtual double GetRegressionAccuracy ()
 
virtual void SetRegressionAccuracy (double _arg)
 
virtual bool GetUseSurrogates ()
 
virtual void SetUseSurrogates (bool _arg)
 
virtual int GetMaxCategories ()
 
virtual void SetMaxCategories (int _arg)
 
virtual bool GetUse1seRule ()
 
virtual void SetUse1seRule (bool _arg)
 
virtual bool GetTruncatePrunedTree ()
 
virtual void SetTruncatePrunedTree (bool _arg)
 
std::vector< float > GetPriors () 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
 

Classification model file compatibility tests

cv::Ptr< cv::ml::DTrees > m_DTreeModel
 
int m_MaxDepth
 
int m_MinSampleCount
 
double m_RegressionAccuracy
 
bool m_UseSurrogates
 
int m_MaxCategories
 
bool m_Use1seRule
 
bool m_TruncatePrunedTree
 
std::vector< float > m_Priors
 
bool CanReadFile (const std::string &) override
 
bool CanWriteFile (const std::string &) override
 
 DecisionTreeMachineLearningModel ()
 
 ~DecisionTreeMachineLearningModel () 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
 
 DecisionTreeMachineLearningModel (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::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >

Definition at line 35 of file otbDecisionTreeMachineLearningModel.h.

Member Typedef Documentation

◆ ConfidenceValueType

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

Definition at line 50 of file otbDecisionTreeMachineLearningModel.h.

◆ ConstPointer

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

Definition at line 42 of file otbDecisionTreeMachineLearningModel.h.

◆ InputListSampleType

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

Definition at line 46 of file otbDecisionTreeMachineLearningModel.h.

◆ InputSampleType

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

Definition at line 45 of file otbDecisionTreeMachineLearningModel.h.

◆ InputValueType

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

Definition at line 44 of file otbDecisionTreeMachineLearningModel.h.

◆ Pointer

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

Definition at line 41 of file otbDecisionTreeMachineLearningModel.h.

◆ ProbaSampleType

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

Definition at line 51 of file otbDecisionTreeMachineLearningModel.h.

◆ Self

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

Standard class typedefs.

Definition at line 39 of file otbDecisionTreeMachineLearningModel.h.

◆ Superclass

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

Definition at line 40 of file otbDecisionTreeMachineLearningModel.h.

◆ TargetListSampleType

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

Definition at line 49 of file otbDecisionTreeMachineLearningModel.h.

◆ TargetSampleType

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

Definition at line 48 of file otbDecisionTreeMachineLearningModel.h.

◆ TargetValueType

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

Definition at line 47 of file otbDecisionTreeMachineLearningModel.h.

Constructor & Destructor Documentation

◆ DecisionTreeMachineLearningModel() [1/2]

template<class TInputValue , class TOutputValue >
otb::DecisionTreeMachineLearningModel< TInputValue, TOutputValue >::DecisionTreeMachineLearningModel
protected

◆ ~DecisionTreeMachineLearningModel()

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

Destructor

◆ DecisionTreeMachineLearningModel() [2/2]

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

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

Member Function Documentation

◆ CanReadFile()

template<class TInputValue , class TOutputValue >
bool otb::DecisionTreeMachineLearningModel< TInputValue, TOutputValue >::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 124 of file otbDecisionTreeMachineLearningModel.hxx.

References CV_TYPE_NAME_ML_TREE.

◆ CanWriteFile()

template<class TInputValue , class TOutputValue >
bool otb::DecisionTreeMachineLearningModel< TInputValue, TOutputValue >::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 151 of file otbDecisionTreeMachineLearningModel.hxx.

◆ CreateAnother()

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

Run-time type information (and related methods).

◆ DoPredict()

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

Predict values using the model

Definition at line 81 of file otbDecisionTreeMachineLearningModel.hxx.

◆ GetMaxCategories()

template<class TInputValue , class TTargetValue >
virtual int otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::GetMaxCategories ( )
virtual

Cluster possible values of a categorical variable into $ K \leq MaxCategories $ clusters to find a suboptimal split. If a discrete variable, on which the training procedure tries to make a split, takes more than max_categories values, the precise best subset estimation may take a very long time because the algorithm is exponential. Instead, many decision trees engines (including ML) try to find sub-optimal split in this case by clustering all the samples into max_categories clusters that is some categories are merged together. The clustering is applied only in n>2-class classification problems for categorical variables with N > max_categories possible values. In case of regression and 2-class classification the optimal split can be found efficiently without employing clustering, thus the parameter is not used in these cases. Default is 10

See also
http://docs.opencv.org/modules/ml/doc/decision_trees.html#CvDTreeParams::CvDTreeParams%28%29

◆ GetMaxDepth()

template<class TInputValue , class TTargetValue >
virtual int otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::GetMaxDepth ( )
virtual

Setters/Getters to the maximum depth of the tree. The maximum possible depth of the tree. That is the training algorithms attempts to split a node while its depth is less than MaxDepth. The actual depth may be smaller if the other termination criteria are met, and/or if the tree is pruned. Default is INT_MAX

See also
http://docs.opencv.org/modules/ml/doc/decision_trees.html#CvDTreeParams::CvDTreeParams%28%29

◆ GetMinSampleCount()

template<class TInputValue , class TTargetValue >
virtual int otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::GetMinSampleCount ( )
virtual

Setters/Getters to the minimum number of sample in each node. If the number of samples in a node is less than this parameter then the node will not be split. Default is 10

See also
http://docs.opencv.org/modules/ml/doc/decision_trees.html#CvDTreeParams::CvDTreeParams%28%29

◆ GetNameOfClass()

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

Run-time type information (and related methods).

◆ GetPriors()

template<class TInputValue , class TTargetValue >
std::vector<float> otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::GetPriors ( ) const
inline

Run-time type information (and related methods).

Definition at line 147 of file otbDecisionTreeMachineLearningModel.h.

◆ GetRegressionAccuracy()

template<class TInputValue , class TTargetValue >
virtual double otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::GetRegressionAccuracy ( )
virtual

Termination Criteria for regression tree. If all absolute differences between an estimated value in a node and values of train samples in this node are less than this parameter then the node will not be split. Default is 0.01

See also
http://docs.opencv.org/modules/ml/doc/decision_trees.html#CvDTreeParams::CvDTreeParams%28%29

◆ GetTruncatePrunedTree()

template<class TInputValue , class TTargetValue >
virtual bool otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::GetTruncatePrunedTree ( )
virtual

If true then pruned branches are physically removed from the tree. Otherwise they are retained and it is possible to get results from the original unpruned (or pruned less aggressively) tree by decreasing CvDTree::pruned_tree_idx parameter. Default is true

See also
http://docs.opencv.org/modules/ml/doc/decision_trees.html#CvDTreeParams::CvDTreeParams%28%29

◆ GetUse1seRule()

template<class TInputValue , class TTargetValue >
virtual bool otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::GetUse1seRule ( )
virtual

If true then a pruning will be harsher. This will make a tree more compact and more resistant to the training data noise but a bit less accurate. Default is true

See also
http://docs.opencv.org/modules/ml/doc/decision_trees.html#CvDTreeParams::CvDTreeParams%28%29

◆ GetUseSurrogates()

template<class TInputValue , class TTargetValue >
virtual bool otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::GetUseSurrogates ( )
virtual

If true then surrogate splits will be built. These splits allow working with missing data and compute variable importance correctly. Default is true

See also
http://docs.opencv.org/modules/ml/doc/decision_trees.html#CvDTreeParams::CvDTreeParams%28%29

◆ Load()

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

Load the model from file

Implements otb::MachineLearningModel< TInputValue, TTargetValue >.

Definition at line 117 of file otbDecisionTreeMachineLearningModel.hxx.

◆ New()

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

Run-time type information (and related methods).

◆ operator=()

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

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

◆ PrintSelf()

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

PrintSelf method

Definition at line 157 of file otbDecisionTreeMachineLearningModel.hxx.

◆ Save()

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

Save the model to file

Implements otb::MachineLearningModel< TInputValue, TTargetValue >.

Definition at line 107 of file otbDecisionTreeMachineLearningModel.hxx.

◆ SetMaxCategories()

template<class TInputValue , class TTargetValue >
virtual void otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::SetMaxCategories ( int  _arg)
virtual

Run-time type information (and related methods).

◆ SetMaxDepth()

template<class TInputValue , class TTargetValue >
virtual void otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::SetMaxDepth ( int  _arg)
virtual

Run-time type information (and related methods).

◆ SetMinSampleCount()

template<class TInputValue , class TTargetValue >
virtual void otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::SetMinSampleCount ( int  _arg)
virtual

Run-time type information (and related methods).

◆ SetRegressionAccuracy()

template<class TInputValue , class TTargetValue >
virtual void otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::SetRegressionAccuracy ( double  _arg)
virtual

Run-time type information (and related methods).

◆ SetTruncatePrunedTree()

template<class TInputValue , class TTargetValue >
virtual void otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::SetTruncatePrunedTree ( bool  _arg)
virtual

Run-time type information (and related methods).

◆ SetUse1seRule()

template<class TInputValue , class TTargetValue >
virtual void otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::SetUse1seRule ( bool  _arg)
virtual

Run-time type information (and related methods).

◆ SetUseSurrogates()

template<class TInputValue , class TTargetValue >
virtual void otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::SetUseSurrogates ( bool  _arg)
virtual

Run-time type information (and related methods).

◆ Train()

template<class TInputValue , class TOutputValue >
void otb::DecisionTreeMachineLearningModel< TInputValue, TOutputValue >::Train
overridevirtual

Train the machine learning model

Implements otb::MachineLearningModel< TInputValue, TTargetValue >.

Definition at line 50 of file otbDecisionTreeMachineLearningModel.hxx.

References CV_VAR_CATEGORICAL, and CV_VAR_NUMERICAL.

Member Data Documentation

◆ m_DTreeModel

template<class TInputValue , class TTargetValue >
cv::Ptr<cv::ml::DTrees> otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::m_DTreeModel
private

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

Definition at line 188 of file otbDecisionTreeMachineLearningModel.h.

◆ m_MaxCategories

template<class TInputValue , class TTargetValue >
int otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::m_MaxCategories
private

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

Definition at line 194 of file otbDecisionTreeMachineLearningModel.h.

◆ m_MaxDepth

template<class TInputValue , class TTargetValue >
int otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::m_MaxDepth
private

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

Definition at line 190 of file otbDecisionTreeMachineLearningModel.h.

◆ m_MinSampleCount

template<class TInputValue , class TTargetValue >
int otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::m_MinSampleCount
private

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

Definition at line 191 of file otbDecisionTreeMachineLearningModel.h.

◆ m_Priors

template<class TInputValue , class TTargetValue >
std::vector<float> otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::m_Priors
private

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

Definition at line 197 of file otbDecisionTreeMachineLearningModel.h.

◆ m_RegressionAccuracy

template<class TInputValue , class TTargetValue >
double otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::m_RegressionAccuracy
private

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

Definition at line 192 of file otbDecisionTreeMachineLearningModel.h.

◆ m_TruncatePrunedTree

template<class TInputValue , class TTargetValue >
bool otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::m_TruncatePrunedTree
private

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

Definition at line 196 of file otbDecisionTreeMachineLearningModel.h.

◆ m_Use1seRule

template<class TInputValue , class TTargetValue >
bool otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::m_Use1seRule
private

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

Definition at line 195 of file otbDecisionTreeMachineLearningModel.h.

◆ m_UseSurrogates

template<class TInputValue , class TTargetValue >
bool otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >::m_UseSurrogates
private

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

Definition at line 193 of file otbDecisionTreeMachineLearningModel.h.


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