20 #ifndef otbDimensionalityReductionTrainPCA_hxx
21 #define otbDimensionalityReductionTrainPCA_hxx
31 template <
class TInputValue,
class TOutputValue>
32 void TrainDimensionalityReductionApplicationBase<TInputValue, TOutputValue>::InitPCAParams()
34 AddChoice(
"algorithm.pca",
"Shark PCA");
35 SetParameterDescription(
"algorithm.pca",
"This group of parameters allows setting Shark PCA parameters. ");
38 AddParameter(
ParameterType_Int,
"algorithm.pca.dim",
"Dimension of the output of the pca transformation");
39 SetParameterInt(
"algorithm.pca.dim", 10,
false);
40 SetParameterDescription(
"algorithm.pca.dim",
"Dimension of the output of the pca transformation.");
43 template <
class TInputValue,
class TOutputValue>
44 void TrainDimensionalityReductionApplicationBase<TInputValue, TOutputValue>::TrainPCA(
typename ListSampleType::Pointer trainingListSample,
45 std::string modelPath)
48 typename PCAModelType::Pointer dimredTrainer = PCAModelType::New();
49 dimredTrainer->SetDimension(GetParameterInt(
"algorithm.pca.dim"));
50 dimredTrainer->SetInputListSample(trainingListSample);
51 dimredTrainer->SetWriteEigenvectors(
true);
52 dimredTrainer->Train();
53 dimredTrainer->Save(modelPath);