[mlpack-svn] [MLPACK] #47: Implement kernel PCA

MLPACK Trac trac at coffeetalk-1.cc.gatech.edu
Sat Nov 26 19:05:43 EST 2011


#47: Implement kernel PCA
----------------------------------------------+-----------------------------
  Reporter:  rcurtin                          |        Owner:            
      Type:  enhancement                      |       Status:  assigned  
  Priority:  major                            |    Milestone:  MLPACK 1.0
 Component:  MLPACK                           |   Resolution:            
  Keywords:  mlpack kernel_pca armadillo std  |     Blocking:            
Blocked By:  126                              |  
----------------------------------------------+-----------------------------

Comment (by rcurtin):

 So we currently have PCA:

 {{{
 class PCA
 {
  public:
   PCA();

   void Apply(const arma::mat& data, arma::mat& transformedData, arma::vec&
              eigVal, arma::mat& coeff);
   void Apply(const arma::mat& data, arma::mat& transformedData,
              arma::vec& eigVal);
   void Apply(arma::mat& data, const int newDimension);

   /**
    * Delete PCA object
    */
   ~PCA();

 }; // class PCA
 }}}

 and we want Kernel PCA:

 {{{
 template<typename Kernel>
 class KernelPCA
 {
  public:
   KernelPCA(const Kernel& kernel);

   void Apply(const arma::mat& data, arma::mat& transformedData, arma::vec&
              eigVal, arma::mat& coeff);
   void Apply(const arma::mat& data, arma::mat& transformedData,
              arma::vec& eigVal);
   void Apply(arma::mat& data, const int newDimension);

   // Accessors / mutators.
   const Kernel& Kernel() const;
   Kernel& kernel();

   ~KernelPCA();

  private:
   Kernel& kernel;
 }; // class KernelPCA
 }}}

 and in that setting, simple PCA is KernelPCA with the LinearKernel.  But
 keep in mind that we can use template specialization to specify different
 (and faster) behavior for that case:

 kernel_pca_impl.hpp:
 {{{
 template< >
 void KernelPCA<LinearKernel>::Apply(..)
 {
   // Now we just use what the old PCA class used.
 }
 }}}

 Once all that is done, we can replace the current PCA class with
 KernelPCA, and then keep a typedef to simple PCA:

 {{{
 typedef KernelPCA<LinearKernel> PCA;
 }}}

-- 
Ticket URL: <http://trac.research.cc.gatech.edu/fastlab/ticket/47#comment:7>
MLPACK <www.fast-lab.org>
MLPACK is an intuitive, fast, and scalable C++ machine learning library developed by the FASTLAB at Georgia Tech under Dr. Alex Gray.


More information about the mlpack-svn mailing list