Skip to content
Snippets Groups Projects
Commit 3fc7ee9a authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: simplify base class LearningApplicationBase

parent 0596e11f
Branches
Tags
No related merge requests found
...@@ -30,27 +30,6 @@ ...@@ -30,27 +30,6 @@
//Estimator //Estimator
#include "otbMachineLearningModelFactory.h" #include "otbMachineLearningModelFactory.h"
#ifdef OTB_USE_OPENCV
#include "otbKNearestNeighborsMachineLearningModel.h"
#include "otbRandomForestsMachineLearningModel.h"
// OpenCV SVM implementation is buggy with linear kernel
// Users should use the libSVM implementation instead.
//#include "otbSVMMachineLearningModel.h"
#include "otbBoostMachineLearningModel.h"
#include "otbDecisionTreeMachineLearningModel.h"
#include "otbGradientBoostedTreeMachineLearningModel.h"
#include "otbNormalBayesMachineLearningModel.h"
#include "otbNeuralNetworkMachineLearningModel.h"
#endif
#ifdef OTB_USE_LIBSVM
#include "otbLibSVMMachineLearningModel.h"
#endif
#ifdef OTB_USE_SHARK
#include "otbSharkRandomForestsMachineLearningModel.h"
#endif
namespace otb namespace otb
{ {
namespace Wrapper namespace Wrapper
...@@ -120,27 +99,6 @@ public: ...@@ -120,27 +99,6 @@ public:
typedef typename ModelType::TargetListSampleType TargetListSampleType; typedef typename ModelType::TargetListSampleType TargetListSampleType;
typedef typename ModelType::TargetValueType TargetValueType; typedef typename ModelType::TargetValueType TargetValueType;
#ifdef OTB_USE_OPENCV
typedef otb::RandomForestsMachineLearningModel<InputValueType, OutputValueType> RandomForestType;
typedef otb::KNearestNeighborsMachineLearningModel<InputValueType, OutputValueType> KNNType;
// OpenCV SVM implementation is buggy with linear kernel
// Users should use the libSVM implementation instead.
// typedef otb::SVMMachineLearningModel<InputValueType, OutputValueType> SVMType;
typedef otb::BoostMachineLearningModel<InputValueType, OutputValueType> BoostType;
typedef otb::DecisionTreeMachineLearningModel<InputValueType, OutputValueType> DecisionTreeType;
typedef otb::GradientBoostedTreeMachineLearningModel<InputValueType, OutputValueType> GradientBoostedTreeType;
typedef otb::NeuralNetworkMachineLearningModel<InputValueType, OutputValueType> NeuralNetworkType;
typedef otb::NormalBayesMachineLearningModel<InputValueType, OutputValueType> NormalBayesType;
#endif
#ifdef OTB_USE_LIBSVM
typedef otb::LibSVMMachineLearningModel<InputValueType, OutputValueType> LibSVMType;
#endif
#ifdef OTB_USE_SHARK
typedef otb::SharkRandomForestsMachineLearningModel<InputValueType, OutputValueType> SharkRandomForestType;
#endif
protected: protected:
LearningApplicationBase(); LearningApplicationBase();
...@@ -178,9 +136,7 @@ private: ...@@ -178,9 +136,7 @@ private:
#ifdef OTB_USE_OPENCV #ifdef OTB_USE_OPENCV
void InitBoostParams(); void InitBoostParams();
// OpenCV SVM implementation is buggy with linear kernel void InitSVMParams();
// Users should use the libSVM implementation instead.
// void InitSVMParams();
void InitDecisionTreeParams(); void InitDecisionTreeParams();
void InitGradientBoostedTreeParams(); void InitGradientBoostedTreeParams();
void InitNeuralNetworkParams(); void InitNeuralNetworkParams();
...@@ -191,11 +147,9 @@ private: ...@@ -191,11 +147,9 @@ private:
void TrainBoost(typename ListSampleType::Pointer trainingListSample, void TrainBoost(typename ListSampleType::Pointer trainingListSample,
typename TargetListSampleType::Pointer trainingLabeledListSample, typename TargetListSampleType::Pointer trainingLabeledListSample,
std::string modelPath); std::string modelPath);
// OpenCV SVM implementation is buggy with linear kernel void TrainSVM(typename ListSampleType::Pointer trainingListSample,
// Users should use the libSVM implementation instead. typename TargetListSampleType::Pointer trainingLabeledListSample,
// void TrainSVM(typename ListSampleType::Pointer trainingListSample, std::string modelPath);
// typename TargetListSampleType::Pointer trainingLabeledListSample,
// std::string modelPath);
void TrainDecisionTree(typename ListSampleType::Pointer trainingListSample, void TrainDecisionTree(typename ListSampleType::Pointer trainingListSample,
typename TargetListSampleType::Pointer trainingLabeledListSample, typename TargetListSampleType::Pointer trainingLabeledListSample,
std::string modelPath); std::string modelPath);
...@@ -238,9 +192,7 @@ private: ...@@ -238,9 +192,7 @@ private:
#include "otbTrainNeuralNetwork.txx" #include "otbTrainNeuralNetwork.txx"
#include "otbTrainNormalBayes.txx" #include "otbTrainNormalBayes.txx"
#include "otbTrainRandomForests.txx" #include "otbTrainRandomForests.txx"
// OpenCV SVM implementation is buggy with linear kernel #include "otbTrainSVM.txx"
// Users should use the libSVM implementation instead.
//#include "otbTrainSVM.txx"
#endif #endif
#ifdef OTB_USE_LIBSVM #ifdef OTB_USE_LIBSVM
#include "otbTrainLibSVM.txx" #include "otbTrainLibSVM.txx"
......
...@@ -147,17 +147,14 @@ LearningApplicationBase<TInputValue,TOutputValue> ...@@ -147,17 +147,14 @@ LearningApplicationBase<TInputValue,TOutputValue>
otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration.");
#endif #endif
} }
else if (modelName == "svm")
// OpenCV SVM implementation is buggy with linear kernel {
// Users should use the libSVM implementation instead. #ifdef OTB_USE_OPENCV
// else if (modelName == "svm") TrainSVM(trainingListSample, trainingLabeledListSample, modelPath);
// { #else
// #ifdef OTB_USE_OPENCV otbAppLogFATAL("Module OPENCV is not installed. You should consider turning OTB_USE_OPENCV on during cmake configuration.");
// TrainSVM(trainingListSample, trainingLabeledListSample, modelPath); #endif
// #else }
// otbAppLogFATAL("Module OPENCV is not installed. You should consider turning OTB_USE_OPENCV on during cmake configuration.");
// #endif
// }
else if (modelName == "boost") else if (modelName == "boost")
{ {
#ifdef OTB_USE_OPENCV #ifdef OTB_USE_OPENCV
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment