Newer
Older
Cédric Traizet
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef cbTrainPCA_txx
#define cbTrainPCA_txx
#include "cbLearningApplicationBaseDR.h"
namespace otb
{
namespace Wrapper
{
template <class TInputValue, class TOutputValue>
void
cbLearningApplicationBaseDR<TInputValue,TOutputValue>
::InitPCAParams()
{
AddChoice("model.pca", "Shark PCA");
SetParameterDescription("model.pca",
"This group of parameters allows setting Shark PCA parameters. "
);
//Output Dimension
AddParameter(ParameterType_Int, "model.pca.dim",
"Dimension of the output of the pca transformation");
SetParameterInt("model.pca.dim",10, false);
SetParameterDescription(
"model.pca.dim",
"Dimension of the output of the pca transformation.");
}
template <class TInputValue, class TOutputValue>
void cbLearningApplicationBaseDR<TInputValue,TOutputValue>
::TrainPCA(typename ListSampleType::Pointer trainingListSample,std::string modelPath)
{
typename PCAModelType::Pointer dimredTrainer = PCAModelType::New();
dimredTrainer->SetDimension(GetParameterInt("model.pca.dim"));
dimredTrainer->SetInputListSample(trainingListSample);
dimredTrainer->Train();
dimredTrainer->Save(modelPath);
}
} //end namespace wrapper
} //end namespace otb
#endif