Opentopia Directory Encyclopedia Tools

Principal components analysis

Encyclopedia : P : PR : PRI : Principal components analysis


In statistics, principal components analysis (PCA) is a technique for simplifying a dataset. It is a linear transformation that transforms the data to a new coordinate system such that the greatest variance by any projection of the data comes to lie on the first coordinate (called the first principal component), the second greatest variance on the second coordinate, and so on. PCA can be used for dimensionality reduction in a dataset while retaining those characteristics of the dataset that contribute most to its variance, by keeping lower-order principal components and ignoring higher-order ones. Such low-order components often contain the "most important" aspects of the data. But this is not necessarily the case, depending on the application.

PCA is also called the (discrete) Karhunen-Loève transform (or KLT, named after Kari Karhunen and Michel Loève) or the Hotelling transform (in honor of Harold Hotelling). PCA has the distinction of being the optimal linear transformation for keeping the subspace that has largest variance. This advantage, however, comes at the price of greater computational requirement if compared, for example, to the discrete cosine transform. Unlike other linear transforms, the PCA does not have a fixed set of basis vectors. Its basis vectors depend on the data set.

Assuming zero empirical mean (the empirical mean of the distribution has been subtracted from the data set), the principal component w1 of a dataset x can be defined as:

[\mathbf_1 = \arg\max_ \Vert = 1} E\left\^T \mathbf\right)^2 \right\}]
(See arg max for the notation.) With the first [k - 1] components, the [k]-th component can be found by subtracting the first [k - 1] principal components from x:
[\mathbf}_ = \mathbf - \sum_^ \mathbf_i \mathbf_i^T \mathbf]
and by substituting this as the new dataset to find a principal component in
[\mathbf_k = \arg\max_ \Vert = 1} E\left\^T \mathbf}_ \right)^2 \right\}.]
The Karhunen-Loève transform is therefore equivalent to finding the singular value decomposition of the data matrix X,

[\mathbf=\mathbf\mathbf\mathbf^T,]
and then obtaining the reduced-space data matrix Y by projecting X down into the reduced space defined by only the first L singular vectors, WL:

[\mathbf=\mathbf^T\mathbf = \mathbf\mathbf^T]
The matrix W of singular vectors of X is equivalently the matrix W of eigenvectors of the matrix of observed covariances C = X XT,

[\mathbf\mathbf^T = \mathbf\mathbf^2\mathbf^T]
The eigenvectors with the largest eigenvalues correspond to the dimensions that have the strongest correlation in the dataset (see Rayleigh quotient).

PCA is equivalent to empirical orthogonal functions (EOF).

PCA is a popular technique in pattern recognition. But it is not optimized for class separability. An alternative is the linear discriminant analysis, which does take this into account. PCA optimally minimizes reconstruction error under the L2 norm.

Table of symbols and abbreviations

Symbol Meaning Dimensions Indices
[\mathbf = \] data matrix, consisting of the set of all data vectors, one vector per column [ M \times N] [ m = 1 \ldots M ]
[ n = 1 \ldots N ]
[N \,] the number of column vectors in the data set [1 \times 1] scalar
[M \,] the number of elements in each column vector [1 \times 1] scalar
[L \,] the number of dimensions in the dimensionally reduced subspace, [ 1 \le L \le M ] [1 \times 1] scalar
[\mathbf = \] vector of empirical means, one mean for each row m of the data matrix [ M \times 1] [ m = 1 \ldots M ]
[\mathbf = \] vector of empirical standard deviations, one standard deviation for each row m of the data matrix [ M \times 1] [ m = 1 \ldots M ]

[\mathbf = \] vector of all 1's [ 1 \times N] [ n = 1 \ldots N ]
[\mathbf = \] deviations from the mean of each row m of the data matrix [ M \times N] [ m = 1 \ldots M ]
[ n = 1 \ldots N ]
[\mathbf = \ ] z-scores, computed using the mean and standard deviation for each row m of the data matrix [ M \times N] [ m = 1 \ldots M ]
[ n = 1 \ldots N ]
[\mathbf = \ ] covariance matrix [ M \times M ] [ p = 1 \ldots M ]
[ q = 1 \ldots M ]
[\mathbf = \ ] correlation matrix [ M \times M ] [ p = 1 \ldots M ]
[ q = 1 \ldots M ]
[ \mathbf = \ ] matrix consisting of the set of all eigenvectors of C, one eigenvector per column [ M \times M ] [ p = 1 \ldots M ]
[ q = 1 \ldots M ]
[\mathbf = \ ] diagonal matrix consisting of the set of all eigenvalues of C along its principal diagonal, and 0 for all other elements [ M \times M ] [ p = 1 \ldots M ]
[ q = 1 \ldots M ]
[\mathbf = \ ] matrix of basis vectors, one vector per column, where each basis vector is one of the eigenvectors of C, and where the vectors in W are a sub-set of those in V [ M \times L] [ p = 1 \ldots M ]
[ q = 1 \ldots L]
[\mathbf = \ ] matrix consisting of N column vectors, where each vector is the projection of the corresponding data vector from matrix X onto the basis vectors contained in the columns of matrix W. [ L \times N] [ m = 1 \ldots L ]
[ n = 1 \ldots N]

Algorithm #1: the covariance method

Following is a detailed description of PCA using the covariance method. The goal is to transform a given data set X of dimension M to an alternative data set Y of smaller dimension L. Equivalently, we are seeking to find the matrix Y, where Y is the Karhunen-Loeve transform (KLT) of matrix X:

[ \mathbf = \mathbb \ \} ]

Organize the data set

Suppose you have data comprising a set of observations of M variables, and you want to reduce the data so that each observation can be described with only L variables, L < M. Suppose further, that the data are arranged as a set of N data vectors [\mathbf_1 \ldots \mathbf_N] with each [\mathbf_n ] representing a single grouped observation of the M variables.

Calculate the empirical mean

:[u[m] = \sum_^N X[m,n] ]

Calculate the deviations from the mean

:[\mathbf = \mathbf - \mathbf \cdot \mathbf ]
:where h is a 1 x N row vector of all 1's:
::[h[n] = 1 \, \qquad \qquad \mathrm n = 1 \ldots N ]

Find the covariance matrix

:[\mathbf = \mathbb \left[ mathbf otimes mathbf right] = \mathbb \left[ mathbf cdot mathbf^ right] = \mathbf \cdot \mathbf^]
:where
::[\mathbb ] is the expected value operator,
::[ \otimes ] is the outer product operator, and
::[ * \ ] is the conjugate transpose operator.

Find the eigenvectors and eigenvalues of the covariance matrix

:[\mathbf \cdot \mathbf = \mathbf \cdot \mathbf ]
:This step will typically require the use of a computer-based algorithm for computing eigenvectors and eigenvalues. These algorithms are readily available as sub-components of most matrix algebra systems, such as MATLAB or Mathematica. See, for example, the [eig function].
:[D[p,q] = \lambda_m \qquad \mathrm \qquad p = q = m]
is the mth eigenvalue of the covariance matrix C, and
:[D[p,q] = 0 \qquad \mathrm \qquad p \ne q.]

Rearrange the eigenvectors and eigenvalues

Compute the cumulative energy content for each eigenvector

:[g[m] = \sum_^m D[p,q] \qquad \mathrm \qquad p = q \qquad \mathrm \qquad m = 1...M ]

Select a subset of the eigenvectors as basis vectors

:[ W[p,q] = V[p,q] \qquad \mathrm \qquad p = 1...M \qquad q = 1...L ]
where
:[1 \leq L \leq M.]
:[ g[m=L] \ge 90% ]

Convert the source data to z-scores

:[ \mathbf = \ = \sqrt \qquad \mathrm p = q = m = 1 \ldots M ]
  • Calculate the M × N z-score matrix:
  • :[ \mathbf = \over \mathbf \cdot \mathbf } ] (divide element-by-element)

    Project the z-scores of the data onto the new basis

    :[ \mathbf = \mathbf^* \cdot \mathbf = \mathbb \ \}.]

    Algorithm #2: the correlation method

    Editor's note: This section is currently undergoing a major revision. See page history for previous revisions.

    Derivation of PCA using the covariance method

    Let X be a d-dimensional random vector expressed as column vector. Without loss of generality, assume X has zero empirical mean. We want to find a [d \times d] orthonormal projection matrix P such that

    [\mathbf = \mathbf^\top \mathbf]
    with the constraint that

    [\operatorname(\mathbf)] is a diagonal matrix and [\mathbf^ = \mathbf^\top.]
    By substitution, and matrix algebra, we obtain:

    [\begin\operatorname(\mathbf) &=& \mathbb[ mathbf mathbf^top]\\\ &=& \mathbb[( mathbf^top mathbf ) ( mathbf^top mathbf )^top]\\\ &=& \mathbb[(mathbf^top mathbf) (mathbf^top mathbf)] \\\ &=& \mathbf^\top \mathbb[mathbf mathbf^top] \mathbf \\\ &=& \mathbf^\top \operatorname(\mathbf) \mathbf\end]
    We now have:

    [\begin\mathbf\operatorname(\mathbf) &=& \mathbf \mathbf^\top \operatorname(\mathbf) \mathbf\\\ &=& \operatorname(\mathbf) \mathbf\\\end]
    Rewrite P as d [d \times 1] column vectors, so

    [\mathbf = [P_1, P_2, ldots, P_d]]
    and [\operatorname(\mathbf)] as:

    [\begin\lambda_1 & \cdots & 0 \\\vdots & \ddots & \vdots \\0 & \cdots & \lambda_d\end.]
    Substituting into equation above, we obtain:

    [[lambda_1 P_1, lambda_2 P_2, ldots, lambda_d P_d] =[operatorname(X)P_1, operatorname(X)P_2,ldots, operatorname(X)P_d].]
    Notice that in [\lambda_i P_i = \operatorname(X)P_i], Pi is an eigenvector of X′s covariance matrix. Therefore, by finding the eigenvectors of X′s covariance matrix, we find a projection matrix P that satisfies the original constraints.

    Correspondence analysis

    Correspondence analysis is conceptually similar to PCA, but scales the data (which must be positive) so that rows and columns are treated equivalently. It is traditionally applied to contingency tables where Pearson's chi-square test has shown a relationship between rows and columns.

    Software/Source Code

    References

    See also

    External links

     


    From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
    All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.

    Search Titles
    0123456789
    ABCDEFGHIJ
    KLMNOPQRST
    UVWXYZ?

    E-mail this article to:

    Personal Message: