/* ********************************************** * MVA variable transformation interface. * * Principal Components Analysis (PCA). * * Author: M.Babai@rug.nl * * LICENSE: * * Version: * * License: * * ********************************************** */ /* * This code is directly based on the Cern Root implementation of PCA. */ #ifndef PND_MVA_VAR_PCA_TRANSFORM_H #define PND_MVA_VAR_PCA_TRANSFORM_H // C & C++ includes #include #include #include #include #include // ROOT includes. #include "TPrincipal.h" class PndMvaVarPCATransform { public: //! Constructor PndMvaVarPCATransform(); //! Destructor. virtual ~PndMvaVarPCATransform(); /** * Prepare Transformation for the given dataset events. *@param dat Collection of the event feature vectors. */ bool InitPCATranformation(std::vector*> > const& dat); /** * Transforms the current event variables *@param evd Vector containing the event to transform. *@return Transformed event. */ std::vector* Transform(std::vector const& evd) const; //! Get mean values vector inline TVectorD const& GetMeanValues() const; //! Get Eigenvectors matrix. inline TMatrixD const& GetEigenVectors() const; //! Set mean values vector. void SetMeanVector(TVectorD const& vect); //! Set Eigenvectors matrix. void SetEigenVectors(TMatrixD const& mat); private: //! To avoid mistakes. PndMvaVarPCATransform (PndMvaVarPCATransform const& ot); PndMvaVarPCATransform &operator=(PndMvaVarPCATransform const& ot); /* * Given a list of n-dimensional data points, Computes PCA for the * current dataset. */ void ComputePrincipalComponents(std::vector< std::pair*> > const& dat); // Mean values TVectorD* m_MeanValues; // Eigenvectors TMatrixD* m_EigenVectors; }; // ENd of interface definition /** * Get mean values vector. */ inline TVectorD const& PndMvaVarPCATransform::GetMeanValues() const { return *m_MeanValues; } /** * Get Eigenvectors matrix. */ inline TMatrixD const& PndMvaVarPCATransform::GetEigenVectors() const { return *m_EigenVectors; } #endif