OTB
9.0.0
Orfeo Toolbox
|
#include <otbMachineLearningModel.h>
Public Types | |
Standard ITK typedefs | |
typedef MachineLearningModel | Self |
typedef itk::Object | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer< const Self > | ConstPointer |
Input related typedefs | |
typedef MLMSampleTraits< TInputValue >::ValueType | InputValueType |
typedef MLMSampleTraits< TInputValue >::SampleType | InputSampleType |
typedef itk::Statistics::ListSample< InputSampleType > | InputListSampleType |
Target related typedefs | |
typedef MLMTargetTraits< TTargetValue >::ValueType | TargetValueType |
typedef MLMTargetTraits< TTargetValue >::SampleType | TargetSampleType |
typedef itk::Statistics::ListSample< TargetSampleType > | TargetListSampleType |
Confidence value typedef | |
typedef MLMTargetTraits< TConfidenceValue >::ValueType | ConfidenceValueType |
typedef MLMTargetTraits< TConfidenceValue >::SampleType | ConfidenceSampleType |
typedef itk::Statistics::ListSample< ConfidenceSampleType > | ConfidenceListSampleType |
typedef itk::VariableLengthVector< double > | ProbaSampleType |
typedef itk::Statistics::ListSample< ProbaSampleType > | ProbaListSampleType |
Public Member Functions | |
Standard macros | |
virtual const char * | GetNameOfClass () const |
virtual void | Train ()=0 |
TargetSampleType | Predict (const InputSampleType &input, ConfidenceValueType *quality=nullptr, ProbaSampleType *proba=nullptr) const |
Set and get the dimension of the model for dimensionality reduction models | |
virtual void | SetDimension (unsigned int _arg) |
virtual unsigned int | GetDimension () |
TargetListSampleType::Pointer | PredictBatch (const InputListSampleType *input, ConfidenceListSampleType *quality=nullptr, ProbaListSampleType *proba=nullptr) const |
Classification model file manipulation | |
virtual void | Save (const std::string &filename, const std::string &name="")=0 |
virtual void | Load (const std::string &filename, const std::string &name="")=0 |
Classification model file compatibility tests | |
virtual bool | CanReadFile (const std::string &)=0 |
virtual bool | CanWriteFile (const std::string &)=0 |
bool | HasConfidenceIndex () const |
bool | HasProbaIndex () const |
Input list of samples accessors | |
virtual void | SetInputListSample (InputListSampleType *_arg) |
itkGetObjectMacro (InputListSample, InputListSampleType) | |
virtual const InputListSampleType * | GetInputListSample () const |
Classification output accessors | |
virtual void | SetTargetListSample (TargetListSampleType *_arg) |
itkGetObjectMacro (TargetListSample, TargetListSampleType) | |
itkGetObjectMacro (ConfidenceListSample, ConfidenceListSampleType) | |
Use model in regression mode | |
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 |
virtual bool | GetRegressionMode () |
void | SetRegressionMode (bool flag) |
MachineLearningModel () | |
~MachineLearningModel () override=default | |
void | PrintSelf (std::ostream &os, itk::Indent indent) const override |
virtual void | DoPredictBatch (const InputListSampleType *input, const unsigned int &startIndex, const unsigned int &size, TargetListSampleType *target, ConfidenceListSampleType *quality=nullptr, ProbaListSampleType *proba=nullptr) const |
virtual TargetSampleType | DoPredict (const InputSampleType &input, ConfidenceValueType *quality=nullptr, ProbaSampleType *proba=nullptr) const =0 |
MachineLearningModel (const Self &)=delete | |
void | operator= (const Self &)=delete |
MachineLearningModel is the base class for all classifier objects (SVM, KNN, Random Forests, Artificial Neural Network, ...) implemented in the supervised classification framework of the OTB.
MachineLearningModel is an abstract object that specifies behavior and interface of supervised classifiers (SVM, KNN, Random Forests, Artificial Neural Network, ...) in the generic supervised classification framework of the OTB. The main generic virtual methods specifically implemented in each classifier derived from the MachineLearningModel class are two learning-related methods: Train() and Save(), and three classification-related methods: Load(), DoPredict() and optionally DoPredictBatch().
Thus, each classifier derived from the MachineLearningModel class computes its corresponding model with Train() and exports it with the help of the Save() method.
It is also possible to classify any input sample composed of several features (or any number of bands in the case of a pixel extracted from a multi-band image) with the help of the Predict() method which needs a previous loading of the classification model with the Load() method.
Definition at line 70 of file otbMachineLearningModel.h.
typedef itk::Statistics::ListSample<ConfidenceSampleType> otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::ConfidenceListSampleType |
Definition at line 98 of file otbMachineLearningModel.h.
typedef MLMTargetTraits<TConfidenceValue>::SampleType otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::ConfidenceSampleType |
Definition at line 97 of file otbMachineLearningModel.h.
typedef MLMTargetTraits<TConfidenceValue>::ValueType otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::ConfidenceValueType |
Definition at line 96 of file otbMachineLearningModel.h.
typedef itk::SmartPointer<const Self> otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::ConstPointer |
Definition at line 78 of file otbMachineLearningModel.h.
typedef itk::Statistics::ListSample<InputSampleType> otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::InputListSampleType |
Definition at line 85 of file otbMachineLearningModel.h.
typedef MLMSampleTraits<TInputValue>::SampleType otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::InputSampleType |
Definition at line 84 of file otbMachineLearningModel.h.
typedef MLMSampleTraits<TInputValue>::ValueType otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::InputValueType |
Definition at line 83 of file otbMachineLearningModel.h.
typedef itk::SmartPointer<Self> otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::Pointer |
Definition at line 77 of file otbMachineLearningModel.h.
typedef itk::Statistics::ListSample<ProbaSampleType> otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::ProbaListSampleType |
Definition at line 102 of file otbMachineLearningModel.h.
typedef itk::VariableLengthVector<double> otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::ProbaSampleType |
Definition at line 101 of file otbMachineLearningModel.h.
typedef MachineLearningModel otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::Self |
Definition at line 75 of file otbMachineLearningModel.h.
typedef itk::Object otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::Superclass |
Definition at line 76 of file otbMachineLearningModel.h.
typedef itk::Statistics::ListSample<TargetSampleType> otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::TargetListSampleType |
Definition at line 92 of file otbMachineLearningModel.h.
typedef MLMTargetTraits<TTargetValue>::SampleType otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::TargetSampleType |
Definition at line 91 of file otbMachineLearningModel.h.
typedef MLMTargetTraits<TTargetValue>::ValueType otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::TargetValueType |
Definition at line 90 of file otbMachineLearningModel.h.
|
protected |
Constructor
Definition at line 36 of file otbMachineLearningModel.hxx.
|
overrideprotecteddefault |
Destructor
|
privatedelete |
Input list sample
|
pure virtual |
Is the input model file readable and compatible with the corresponding classifier ?
Implemented in otb::AutoencoderModel< TInputValue, NeuronType >, otb::PCAModel< TInputValue >, otb::SOMModel< TInputValue, MapDimension >, otb::NeuralNetworkMachineLearningModel< TInputValue, TTargetValue >, otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >, otb::SharkKMeansMachineLearningModel< TInputValue, TTargetValue >, otb::SharkRandomForestsMachineLearningModel< TInputValue, TTargetValue >, otb::BoostMachineLearningModel< TInputValue, TTargetValue >, otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >, otb::LibSVMMachineLearningModel< TInputValue, TTargetValue >, otb::RandomForestsMachineLearningModel< TInputValue, TTargetValue >, otb::SVMMachineLearningModel< TInputValue, TTargetValue >, and otb::NormalBayesMachineLearningModel< TInputValue, TTargetValue >.
|
pure virtual |
Is the input model file writable and compatible with the corresponding classifier ?
Implemented in otb::AutoencoderModel< TInputValue, NeuronType >, otb::PCAModel< TInputValue >, otb::SOMModel< TInputValue, MapDimension >, otb::NeuralNetworkMachineLearningModel< TInputValue, TTargetValue >, otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >, otb::SharkKMeansMachineLearningModel< TInputValue, TTargetValue >, otb::SharkRandomForestsMachineLearningModel< TInputValue, TTargetValue >, otb::BoostMachineLearningModel< TInputValue, TTargetValue >, otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >, otb::LibSVMMachineLearningModel< TInputValue, TTargetValue >, otb::RandomForestsMachineLearningModel< TInputValue, TTargetValue >, otb::SVMMachineLearningModel< TInputValue, TTargetValue >, and otb::NormalBayesMachineLearningModel< TInputValue, TTargetValue >.
|
privatepure virtual |
Actual implementation of single sample prediction
input | sample to predict |
quality | Pointer to a variable to store confidence value, or NULL |
|
privatevirtual |
Actual implementation of BatchPredicition Default implementation will call DoPredict iteratively
input | The input batch |
startIndex | Index of the first sample to predict |
size | Number of samples to predict |
target | Pointer to the list of produced labels |
quality | Pointer to the list of produced confidence values, or NULL |
Override me if internal implementation allows for batch prediction.
Also set m_IsDoPredictBatchMultiThreaded to true if internal implementation allows for parallel batch prediction.
Definition at line 130 of file otbMachineLearningModel.hxx.
|
virtual |
Predict a batch of samples (InputListSampleType)
input | The batch of sample to predict |
quality | A pointer to the list were to store quality value, or NULL |
|
virtual |
|
virtual |
Run-time type information (and related methods).
|
virtual |
Input list sample
|
inline |
Query capacity to produce a confidence index
Definition at line 160 of file otbMachineLearningModel.h.
|
inline |
Query capacity to produce probability values
Definition at line 166 of file otbMachineLearningModel.h.
otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::itkGetObjectMacro | ( | ConfidenceListSample | , |
ConfidenceListSampleType | |||
) |
Set the target labels (to be used before training)
otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::itkGetObjectMacro | ( | InputListSample | , |
InputListSampleType | |||
) |
otb::MachineLearningModel< TInputValue, TTargetValue, TConfidenceValue >::itkGetObjectMacro | ( | TargetListSample | , |
TargetListSampleType | |||
) |
Get the target labels
|
pure virtual |
Load the model from file
Implemented in otb::NeuralNetworkMachineLearningModel< TInputValue, TTargetValue >, otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >, otb::AutoencoderModel< TInputValue, NeuronType >, otb::SharkKMeansMachineLearningModel< TInputValue, TTargetValue >, otb::SharkRandomForestsMachineLearningModel< TInputValue, TTargetValue >, otb::PCAModel< TInputValue >, otb::SOMModel< TInputValue, MapDimension >, otb::BoostMachineLearningModel< TInputValue, TTargetValue >, otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >, otb::LibSVMMachineLearningModel< TInputValue, TTargetValue >, otb::RandomForestsMachineLearningModel< TInputValue, TTargetValue >, otb::SVMMachineLearningModel< TInputValue, TTargetValue >, and otb::NormalBayesMachineLearningModel< TInputValue, TTargetValue >.
|
privatedelete |
Input list sample
MachineLearningModel< TInputValue, TOutputValue, TConfidenceValue >::TargetSampleType otb::MachineLearningModel< TInputValue, TOutputValue, TConfidenceValue >::Predict | ( | const InputSampleType & | input, |
ConfidenceValueType * | quality = nullptr , |
||
ProbaSampleType * | proba = nullptr |
||
) | const |
Predict a single sample
input | The sample |
quality | A pointer to the quality variable were to store quality value, or NULL |
Definition at line 62 of file otbMachineLearningModel.hxx.
MachineLearningModel< TInputValue, TOutputValue, TConfidenceValue >::TargetListSampleType::Pointer otb::MachineLearningModel< TInputValue, TOutputValue, TConfidenceValue >::PredictBatch | ( | const InputListSampleType * | input, |
ConfidenceListSampleType * | quality = nullptr , |
||
ProbaListSampleType * | proba = nullptr |
||
) | const |
Predict a batch of samples (InputListSampleType)
input | The batch of sample to predict |
quality | A pointer to the list were to store quality value, or NULL |
Definition at line 72 of file otbMachineLearningModel.hxx.
|
overrideprotected |
PrintSelf method
Definition at line 181 of file otbMachineLearningModel.hxx.
|
pure virtual |
Save the model to file
Implemented in otb::NeuralNetworkMachineLearningModel< TInputValue, TTargetValue >, otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >, otb::AutoencoderModel< TInputValue, NeuronType >, otb::SharkKMeansMachineLearningModel< TInputValue, TTargetValue >, otb::PCAModel< TInputValue >, otb::SharkRandomForestsMachineLearningModel< TInputValue, TTargetValue >, otb::SOMModel< TInputValue, MapDimension >, otb::BoostMachineLearningModel< TInputValue, TTargetValue >, otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >, otb::LibSVMMachineLearningModel< TInputValue, TTargetValue >, otb::RandomForestsMachineLearningModel< TInputValue, TTargetValue >, otb::SVMMachineLearningModel< TInputValue, TTargetValue >, and otb::NormalBayesMachineLearningModel< TInputValue, TTargetValue >.
|
virtual |
Predict a batch of samples (InputListSampleType)
input | The batch of sample to predict |
quality | A pointer to the list were to store quality value, or NULL |
|
virtual |
void otb::MachineLearningModel< TInputValue, TOutputValue, TConfidenceValue >::SetRegressionMode | ( | bool | flag | ) |
Input list sample
Definition at line 47 of file otbMachineLearningModel.hxx.
|
virtual |
Set the target labels (to be used before training)
|
pure virtual |
Train the machine learning model
Implemented in otb::NeuralNetworkMachineLearningModel< TInputValue, TTargetValue >, otb::DecisionTreeMachineLearningModel< TInputValue, TTargetValue >, otb::AutoencoderModel< TInputValue, NeuronType >, otb::SharkKMeansMachineLearningModel< TInputValue, TTargetValue >, otb::PCAModel< TInputValue >, otb::SOMModel< TInputValue, MapDimension >, otb::SharkRandomForestsMachineLearningModel< TInputValue, TTargetValue >, otb::BoostMachineLearningModel< TInputValue, TTargetValue >, otb::KNearestNeighborsMachineLearningModel< TInputValue, TTargetValue >, otb::LibSVMMachineLearningModel< TInputValue, TTargetValue >, otb::RandomForestsMachineLearningModel< TInputValue, TTargetValue >, otb::SVMMachineLearningModel< TInputValue, TTargetValue >, and otb::NormalBayesMachineLearningModel< TInputValue, TTargetValue >.
|
protected |
flag that tells if the model support confidence index output
Definition at line 228 of file otbMachineLearningModel.h.
|
protected |
Input list sample
Definition at line 217 of file otbMachineLearningModel.h.
|
protected |
Output Dimension of the model, used by Dimensionality Reduction models
Definition at line 237 of file otbMachineLearningModel.h.
|
protected |
Input list sample
Definition at line 209 of file otbMachineLearningModel.h.
|
protected |
Is DoPredictBatch multi-threaded ?
Definition at line 234 of file otbMachineLearningModel.h.
|
protected |
flag that indicates if the model supports regression, child classes should modify it in their constructor if they support regression mode
Definition at line 225 of file otbMachineLearningModel.h.
|
protected |
flag that tells if the model support probability output
Definition at line 231 of file otbMachineLearningModel.h.
|
protected |
flag to choose between classification and regression modes
Definition at line 220 of file otbMachineLearningModel.h.
|
protected |
Target list sample
Definition at line 215 of file otbMachineLearningModel.h.
|
protected |
Validation list sample if provided for some models
Definition at line 212 of file otbMachineLearningModel.h.