source: trunk/yat/utility/KernelPCA.h @ 2324

Last change on this file since 2324 was 2324, checked in by Peter, 12 years ago

new class KernelPCA. closes #639

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1#ifndef _theplu_yat_utility_kernel_pca_
2#define _theplu_yat_utility_kernel_pca_
3
4// $Id: KernelPCA.h 2324 2010-09-21 21:19:25Z peter $
5
6/*
7  Copyright (C) 2010 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25namespace theplu {
26namespace yat {
27namespace classifier {
28  class MatrixLookup;
29}
30namespace utility {
31
32  class Matrix;
33  class Vector;
34
35  /**
36     \brief Principal Component Analysis on a Kernel Matrix
37
38     This class performs PCA on a kernel matrix. Note that this class
39     does not diagonalize the kernel matrix to find eigen-samples that
40     maximizes the variance (use class SVD). Instead, this class finds
41     eigen-features that maximizes the variance in feature space and
42     projects the data onto these eigen-features.
43
44     As the covariance of features is not available nor is the data,
45     we create a data matrix Z that fulfills Kernel = Z' * Z. As this
46     data matrix Z has the same kernel matrix as the original data and
47     thus also same distances between each pair of sample, the
48     difference between Z and original data matrix is at most a
49     rotation and translation. Hence, the projection of Z onto the
50     first principial components will be equivalent to the projection
51     of original data onto its principal components.
52
53     \see PCA
54
55     \since New in yat 0.7
56  */
57  class KernelPCA
58  {
59  public:
60    /**
61       Constructor taking the kernel matrix as input. \a kernel is
62       expected to be symmetric and positive semi-definite.
63
64       The \a kernel matrix contains the scalar product between all
65       samples, i.e., element kernel(i,j) is the scalar product
66       between sample i and sample j.
67    */
68    explicit KernelPCA(const Matrix& kernel);
69   
70    /**
71       \brief destructor
72     */
73    virtual ~KernelPCA(void);
74
75    /**
76       \brief sorted eigenvalues.
77
78       \return eigenvalues sorted such eignenvalues(0) is the largest value
79    */
80    const Vector& eigenvalues(void) const;
81
82    /**
83       This function will project data onto the new coordinate-system.
84
85       Each column corresponds to a sample.
86    */
87    const Matrix& projection(void) const;
88
89  private:
90    class Impl;
91    Impl* impl_;
92};
93
94}}} // of namespace utility, yat, and theplu
95
96#endif
Note: See TracBrowser for help on using the repository browser.