Skip to content
Snippets Groups Projects
Commit 0887295c authored by Cédric Traizet's avatar Cédric Traizet
Browse files

PCA now outputs Eigenvectors and eigenvalues in a txt file

parent 1b8af99c
No related branches found
No related tags found
1 merge request!4Dimensionality reduction algorithms
......@@ -78,6 +78,16 @@ void PCAModel<TInputValue>::Save(const std::string & filename, const std::string
boost::archive::polymorphic_text_oarchive oa(ofs);
m_encoder.write(oa);
ofs.close();
if (this->m_WriteEigenvectors == true) // output the map vectors in a txt file
{
std::ofstream otxt(filename+".txt");
otxt << m_pca.eigenvectors() << std::endl;
otxt << m_pca.eigenvalues() << std::endl;
otxt.close();
}
}
template <class TInputValue>
......@@ -109,6 +119,8 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string
m_encoder.setStructure(eigenvectors, m_encoder.offset() );
std::cout << m_encoder.matrix() << "end" << std::endl;
//this->m_Size = m_NumberOfHiddenNeurons;
}
......
......@@ -40,6 +40,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue>
typename PCAModelType::Pointer dimredTrainer = PCAModelType::New();
dimredTrainer->SetDimension(GetParameterInt("model.pca.dim"));
dimredTrainer->SetInputListSample(trainingListSample);
dimredTrainer->SetWriteEigenvectors(true);
dimredTrainer->Train();
dimredTrainer->Save(modelPath);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment