Unsupervised and Supervised Principal Component Analysis: Tutorial

Unsupervised and Supervised Principal Component Analysis: Tutorial

Unsupervised and Supervised Principal Component Analysis: Tutorial Benyamin Ghojogh [email protected] Department of Electrical and Computer Engineering, Machine Learning Laboratory, University of Waterloo, Waterloo, ON, Canada Mark Crowley [email protected] Department of Electrical and Computer Engineering, Machine Learning Laboratory, University of Waterloo, Waterloo, ON, Canada Abstract space and manifold learning (Friedman et al., 2009). This This is a detailed tutorial paper which explains method, which is also used for feature extraction (Ghojogh the Principal Component Analysis (PCA), Su- et al., 2019b), was first proposed by (Pearson, 1901). In or- pervised PCA (SPCA), kernel PCA, and kernel der to learn a nonlinear sub-manifold, kernel PCA was pro- SPCA. We start with projection, PCA with eigen- posed, first by (Scholkopf¨ et al., 1997; 1998), which maps decomposition, PCA with one and multiple pro- the data to high dimensional feature space hoping to fall on jection directions, properties of the projection a linear manifold in that space. matrix, reconstruction error minimization, and The PCA and kernel PCA are unsupervised methods for we connect to auto-encoder. Then, PCA with sin- subspace learning. To use the class labels in PCA, super- gular value decomposition, dual PCA, and ker- vised PCA was proposed (Bair et al., 2006) which scores nel PCA are covered. SPCA using both scor- the features of the X and reduces the features before ap- ing and Hilbert-Schmidt independence criterion plying PCA. This type of SPCA were mostly used in bioin- are explained. Kernel SPCA using both direct formatics (Ma & Dai, 2011). and dual approaches are then introduced. We Afterwards, another type of SPCA (Barshan et al., 2011) cover all cases of projection and reconstruction was proposed which has a very solid theory and PCA is of training and out-of-sample data. Finally, some really a special case of it when we the labels are not used. simulations are provided on Frey and AT&T face This SPCA also has dual and kernel SPCA. datasets for verifying the theory in practice. The PCA and SPCA have had many applications for ex- ample eigenfaces (Turk & Pentland, 1991a;b) and kernel 1. Introduction eigenfaces (Yang et al., 2000) for face recognition and de- tecting orientation of image using PCA (Mohammadzade Assume we have a dataset of instances or data points n et al., 2017). There exist many other applications of PCA f(xi; yi)gi=1 with sample size n and dimensionality xi 2 d ` n and SPCA in the literature. In this paper, we explain the R and yi 2 R . The fxigi=1 are the input data to n theory of PCA, kernel SPCA, SPCA, and kernel SPCA and the model and the fyigi=1 are the observations (labels). d×n `×n provide some simulations for verifying the theory in prac- We define R 3 X := [x1;:::; xn] and R 3 arXiv:1906.03148v1 [stat.ML] 1 Jun 2019 tice. Y := [y1;:::; yn]. We can also have an out-of-sample d data point, xt 2 R , which is not in the training set. If nt 2. Principal Component Analysis there are nt out-of-sample data points, fxt;ig1 , we define d×nt 2.1. Projection Formulation R 3 Xt := [xt;1;:::; xt;nt ]. Usually, the data points exist on a subspace or sub-manifold. Subspace or manifold 2.1.1. A PROJECTION POINT OF VIEW learning tries to learn this sub-manifold (Ghojogh et al., d Assume we have a data point x 2 R . We want to project 2019b). this data point onto the vector space spanned by p vectors Principal Component Analysis (PCA) (Jolliffe, 2011) is a fu1;:::; upg where each vector is d-dimensional and usu- very well-known and fundamental linear method for sub- ally p d. We stack these vectors column-wise in matrix d×p U = [u1;:::; up] 2 R . In other words, we want to project x onto the column space of U, denoted by Col(U). The projection of x 2 Rd onto Col(U) 2 Rp and then its Unsupervised and Supervised Principal Component Analysis: Tutorial 2 Figure 1. The residual and projection onto the column space of U. representation in the Rd (its reconstruction) can be seen as a linear system of equations: d R 3 xb := Uβ; (1) Figure 2. The principal directions P1 and P2 for (a) non-centered p and (b) centered data. As can be seen, the data should be centered where we should find the unknown coefficients β 2 R . for PCA. If the x lies in the Col(U) or spanfu1;:::; upg, this linear system has exact solution, so xb = x = Uβ. However, if x does not lie in this space, there is no any solution β for So, we have: x = Uβ and we should solve for projection of x onto > xb = Π x = UU x: (6) Col(U) or spanfu1;:::; upg and then its reconstruction. In other words, we should solve for Eq. (1). In this case, xb and x are different and we have a residual: 2.1.2. PROJECTION AND RECONSTRUCTION IN PCA The Eq. (6) can be interpreted in this way: The U >x r = x − x = x − Uβ; (2) > b projects x onto the row space of U, i.e., Col(U ) (pro- which we want to be small. As can be seen in Fig.1, the jection onto a space spanned by d vectors which are p- dimensional). We call this projection, “projection onto the smallest residual vector is orthogonal to Col(U); therefore: PCA subspace”. It is “subspace” because we have p ≤ d x − Uβ ? U =) U >(x − Uβ) = 0; where p and d are dimensionality of PCA subspace and > > > x U(U x) =) β = (U U)−1U x: (3) the original , respectively. Afterwards, projects the projected data back onto the column space of U, i.e., It is noteworthy that the Eq. (3) is also the formula of co- Col(U) (projection onto a space spanned by p vectors efficients in linear regression (Friedman et al., 2009) where which are d-dimensional). We call this step “reconstruc- the input data are the rows of U and the labels are x; how- tion from the PCA” and we want the residual between x ever, our goal here is different. Nevertheless, in Section and its reconstruction xb to be small. n 2.4, some similarities of PCA and regression will be intro- If there exist n training data points, i.e., fxigi=1, the pro- duced. jection of a training data point x is: Plugging Eq. (3) in Eq. (1) gives us: p > R 3 x := U x˘; (7) > −1 > e xb = U(U U) U x: where: We define: d 3 x˘ := x − µ ; (8) d×d > −1 > R x R 3 Π := U(U U) U ; (4) is the centered data point and: as “projection matrix” because it projects x onto Col(U) n (and reconstructs back). Note that Π is also referred to as 1 X d 3 µ := x ; (9) the “hat matrix” in the literature because it puts a hat on top R x n i of x. i=1 If the vectors fu1;:::; upg are orthonormal (the matrix U is the mean of training data points. The reconstruction of is orthogonal), we have U > = U −1 and thus U >U = I. a training data point x after projection onto the PCA sub- Therefore, Eq. (4) is simplified: space is: > d > Π = UU : (5) R 3 xb := UU x˘ + µx = Uxe + µx; (10) Unsupervised and Supervised Principal Component Analysis: Tutorial 3 d×nt where the mean is added back because it was removed be- If we consider the nt out-of-sample data points, R 3 fore projection. Xt = [xt;1;:::; xt;nt ], all together, the projection and re- Note that in PCA, all the data points should be centered, construction of them are: i.e., the mean should be removed first. The reason is shown p×nt > ˘ in Fig.2. In some applications, centering the data does not R 3 Xft = U Xt; (18) make sense. For example, in natural language processing, d×nt > ˘ R 3 Xct = UU Xt + µx = UXft + µx; (19) the data are text and centering the data makes some nega- tive measures which is non-sense for text. Therefore, data respectively, where: is not sometimes centered and PCA is applied on the non- d×nt ˘ centered data. This method is called Latent Semantic In- R 3 Xt := Xt − µx: (20) dexing (LSI) or Latent Semantic Analysis (LSA) (Dumais, 2004). 2.2. PCA Using Eigen-Decomposition If we stack the n data points column-wise in a matrix X = 2.2.1. PROJECTION ONTO ONE DIRECTION d×n [x1;:::; xn] 2 R , we first center them: In Eq. (10), if p = 1, we are projecting x onto only one vector u and reconstruct it. If we ignore adding the mean d×n ˘ R 3 X := XH = X − µx; (11) back, we have: where X˘ = [x˘ ;:::; x˘ ] = [x − µ ;:::; x − µ ] is the > 1 n 1 x n x xb = uu x˘: centered data and: The squared length (squared `2-norm) of this reconstructed n×n > R 3 H := I − (1=n)11 ; (12) vector is: is the centering matrix. See AppendixA for more details 2 > 2 > > > jjxbjj2 = jjuu x˘jj2 = (uu x˘) (uu x˘) about the centering matrix. > > > (a) > > (b) > > The projection and reconstruction, Eqs. (7) and (10), for = x˘ u u u u x˘ = x˘ u u x˘ = u x˘ x˘ u; (21) |{z} the whole training data are: 1 p×n > ˘ where (a) is because u is a unit (normal) vector, i.e., R 3 Xf := U X; (13) > 2 > > u u = jjujj2 = 1, and (b) is because x˘ u = u x˘ 2 R.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    25 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us