Request for changes-102: Extend MachineLearningModel sample and target types
Contents
Status
- Author: Julien Michel (CNES)
- Submitted on 21.07.2017
- Proposed target release: 6.2
- Adopted : +4 (Julien, Victor, Rémi, Guillaume)
- Merged : 61334ae8204eb84f99de859d0aa018556eb01ddf
Summary
The goal of this pull request is to be able to use itk::VariableLengthVector<> as Target type in otb::MachineLearningModel, so as to avoid code duplication when the following remote module will be merged in otb:
http://tully.ups-tlse.fr/traizetc/cb_dimensionality_reduction
Rationale
Currently, MachineLearningModel excepts scalar types TSample and TTarget and defines
TargetSampleType = itk::FixedArray<TTarget,1> InputSampleType = itk::VariableLenghtVector<TSample>
It is therefore impossible to use different containers for TargetSampleType and InputSampleType.
Implementation details
The main idea of this RFC is that MachineLearningModel will use MachineLearningModelTraits to define TargetSampleType and InputSampleType. The traits will then switch beween two cases: if TTarget (resp. TSample) is a scalar type, it will use the current containers typedef, and if TTarget is a container itself, it will use it instead:
Using those traits allows to reach the goal with a very limited impact on MachineLearningModel, and not a single line of code changes in derived classes.
Classes and files
New traits are defined in:
Modules/Learning/LearningBase/include/otbMachineLearningModelTraits.h
The otb::MachineLearningModel class has been updated to use the new traits:
Modules/Learning/LearningBase/include/otbMachineLearningModel.h
Tests
Modules/Learning/LearningBase/test/otbMachineLearningModelTemplates.cxx
has been extended to test that we can
typedef otb::MachineLearningModel<float,itk::VariableLengthVector<double>> MachineLearningModelType2;
Documentation
Doxygen documentation is provided for MachineLearningModelTraits.