当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

北京大学:《模式识别》课程教学资源(参考资料)A Tutorial on Principal Component Analysis

资源类别:文库,文档格式:PDF,文档页数:12,文件大小:323.65KB,团购合买
点击下载完整版文档(PDF)

A Tutorial on Principal Component Analysis Jonathon Shlens* Center for Neural Science,New York University New York City.NY 10003-6603 and Systems Neurobiology Laboratory,Salk Insitute for Biological Studies La Jolla,CA 92037 (Dated:April 22,2009;Version 3.01) Principal component analysis (PCA)is a mainstay of modern data analysis-a black box that is widely used but (sometimes)poorly understood.The goal of this paper is to dispel the magic behind this black box.This manuscript focuses on building a solid intuition for how and why principal component analysis works.This manuscript crystallizes this knowledge by deriving from simple intuitions,the mathematics behind PCA.This tutorial does not shy away from explaining the ideas informally,nor does it shy away from the mathematics.The hope is that by addressing both aspects,readers of all levels will be able to gain a better understanding of PCA as well as the when,the how and the why of applying this technique I.INTRODUCTION Il.MOTIVATION:A TOY EXAMPLE Principal component analysis(PCA)is a standard tool in mod- Here is the perspective:we are an experimenter.We are trying ern data analysis-in diverse fields from neuroscience to com- to understand some phenomenon by measuring various quan- puter graphics-because it is a simple,non-parametric method tities (e.g.spectra,voltages,velocities,etc.)in our system. for extracting relevant information from confusing data sets. Unfortunately,we can not figure out what is happening be- With minimal effort PCA provides a roadmap for how to re- cause the data appears clouded,unclear and even redundant duce a complex data set to a lower dimension to reveal the This is not a trivial problem,but rather a fundamental obstacle sometimes hidden,simplified structures that often underlie it. in empirical science.Examples abound from complex sys- The goal of this tutorial is to provide both an intuitive feel for tems such as neuroscience,web indexing,meteorology and oceanography-the number of variables to measure can be PCA,and a thorough discussion of this topic.We will begin with a simple example and provide an intuitive explanation unwieldy and at times even deceptive,because the underlying of the goal of PCA.We will continue by adding mathemati- relationships can often be quite simple cal rigor to place it within the framework of linear algebra to Take for example a simple toy problem from physics dia- provide an explicit solution.We will see how and why PCA grammed in Figure 1.Pretend we are studying the motion is intimately related to the mathematical technique of singular of the physicist's ideal spring.This system consists of a ball value decomposition(SVD).This understanding will lead us of mass m attached to a massless,frictionless spring.The ball to a prescription for how to apply PCA in the real world and an is released a small distance away from equilibrium (i.e.the appreciation for the underlying assumptions.My hope is that spring is stretched).Because the spring is ideal,it oscillates a thorough understanding of PCA provides a foundation for indefinitely along the x-axis about its equilibrium at a set fre- approaching the fields of machine learning and dimensional quency. reduction. This is a standard problem in physics in which the motion The discussion and explanations in this paper are informal in along the x direction is solved by an explicit function of time. the spirit of a tutorial.The goal of this paper is to educate. In other words,the underlying dynamics can be expressed as Occasionally,rigorous mathematical proofs are necessary al- a function of a single variable x. though relegated to the Appendix.Although not as vital to the tutorial,the proofs are presented for the adventurous reader However,being ignorant experimenters we do not know any who desires a more complete understanding of the math.My of this.We do not know which,let alone how many,axes only assumption is that the reader has a working knowledge and dimensions are important to measure.Thus,we decide to of linear algebra.My goal is to provide a thorough discussion measure the ball's position in a three-dimensional space (since by largely building on ideas from linear algebra and avoiding we live in a three dimensional world).Specifically,we place challenging topics in statistics and optimization theory (but three movie cameras around our system of interest.At 120 Hz see Discussion).Please feel free to contact me with any sug- each movie camera records an image indicating a two dimen- gestions,corrections or comments. sional position of the ball(a projection).Unfortunately,be- cause of our ignorance,we do not even know what are the real x,y and z axes,so we choose three camera positions a.b and c at some arbitrary angles with respect to the system.The angles "Electronic address:shlensesalk.edu between our measurements might not even be 90!Now,we

A Tutorial on Principal Component Analysis Jonathon Shlens∗ Center for Neural Science, New York University New York City, NY 10003-6603 and Systems Neurobiology Laboratory, Salk Insitute for Biological Studies La Jolla, CA 92037 (Dated: April 22, 2009; Version 3.01) Principal component analysis (PCA) is a mainstay of modern data analysis - a black box that is widely used but (sometimes) poorly understood. The goal of this paper is to dispel the magic behind this black box. This manuscript focuses on building a solid intuition for how and why principal component analysis works. This manuscript crystallizes this knowledge by deriving from simple intuitions, the mathematics behind PCA. This tutorial does not shy away from explaining the ideas informally, nor does it shy away from the mathematics. The hope is that by addressing both aspects, readers of all levels will be able to gain a better understanding of PCA as well as the when, the how and the why of applying this technique. I. INTRODUCTION Principal component analysis (PCA) is a standard tool in mod￾ern data analysis - in diverse fields from neuroscience to com￾puter graphics - because it is a simple, non-parametric method for extracting relevant information from confusing data sets. With minimal effort PCA provides a roadmap for how to re￾duce a complex data set to a lower dimension to reveal the sometimes hidden, simplified structures that often underlie it. The goal of this tutorial is to provide both an intuitive feel for PCA, and a thorough discussion of this topic. We will begin with a simple example and provide an intuitive explanation of the goal of PCA. We will continue by adding mathemati￾cal rigor to place it within the framework of linear algebra to provide an explicit solution. We will see how and why PCA is intimately related to the mathematical technique of singular value decomposition (SVD). This understanding will lead us to a prescription for how to apply PCA in the real world and an appreciation for the underlying assumptions. My hope is that a thorough understanding of PCA provides a foundation for approaching the fields of machine learning and dimensional reduction. The discussion and explanations in this paper are informal in the spirit of a tutorial. The goal of this paper is to educate. Occasionally, rigorous mathematical proofs are necessary al￾though relegated to the Appendix. Although not as vital to the tutorial, the proofs are presented for the adventurous reader who desires a more complete understanding of the math. My only assumption is that the reader has a working knowledge of linear algebra. My goal is to provide a thorough discussion by largely building on ideas from linear algebra and avoiding challenging topics in statistics and optimization theory (but see Discussion). Please feel free to contact me with any sug￾gestions, corrections or comments. ∗Electronic address: shlens@salk.edu II. MOTIVATION: A TOY EXAMPLE Here is the perspective: we are an experimenter. We are trying to understand some phenomenon by measuring various quan￾tities (e.g. spectra, voltages, velocities, etc.) in our system. Unfortunately, we can not figure out what is happening be￾cause the data appears clouded, unclear and even redundant. This is not a trivial problem, but rather a fundamental obstacle in empirical science. Examples abound from complex sys￾tems such as neuroscience, web indexing, meteorology and oceanography - the number of variables to measure can be unwieldy and at times even deceptive, because the underlying relationships can often be quite simple. Take for example a simple toy problem from physics dia￾grammed in Figure 1. Pretend we are studying the motion of the physicist’s ideal spring. This system consists of a ball of mass m attached to a massless, frictionless spring. The ball is released a small distance away from equilibrium (i.e. the spring is stretched). Because the spring is ideal, it oscillates indefinitely along the x-axis about its equilibrium at a set fre￾quency. This is a standard problem in physics in which the motion along the x direction is solved by an explicit function of time. In other words, the underlying dynamics can be expressed as a function of a single variable x. However, being ignorant experimenters we do not know any of this. We do not know which, let alone how many, axes and dimensions are important to measure. Thus, we decide to measure the ball’s position in a three-dimensional space (since we live in a three dimensional world). Specifically, we place three movie cameras around our system of interest. At 120 Hz each movie camera records an image indicating a two dimen￾sional position of the ball (a projection). Unfortunately, be￾cause of our ignorance, we do not even know what are the real x, y and z axes, so we choose three camera positions~a,~b and~c at some arbitrary angles with respect to the system. The angles between our measurements might not even be 90o ! Now, we

Determining this fact allows an experimenter to discern which dynamics are important,redundant or noise. amera C A.A Naive Basis With a more precise definition of our goal,we need a more precise definition of our data as well.We treat every time sample(or experimental trial)as an individual sample in our data set.At each time sample we record a set of data consist- ing of multiple measurements (e.g.voltage,position,etc.).In our data set,at one point in time,camera A records a corre- sponding ball position (xA,yA).One sample or trial can then camera A camera B camera C be expressed as a 6 dimensional column vector XA yA XB YB XC FIG.1 A toy example.The position of a ball attached to an oscillat- where each camera contributes a 2-dimensional projection of ing spring is recorded using three cameras A,B and C.The position the ball's position to the entire vector X.If we record the ball's of the ball tracked by each camera is depicted in each panel below. position for 10 minutes at 120 Hz,then we have recorded 10x 60x 120=72000 of these vectors. record with the cameras for several minutes.The big question With this concrete example,let us recast this problem in ab- remains:how do we get from this data set to a simple equation stract terms.Each sample X is an m-dimensional vector, ofx? where m is the number of measurement types.Equivalently, every sample is a vector that lies in an m-dimensional vec- We know a-priori that if we were smart experimenters,we tor space spanned by some orthonormal basis.From linear would have just measured the position along the x-axis with algebra we know that all measurement vectors form a linear one camera.But this is not what happens in the real world. combination of this set of unit length basis vectors.What is We often do not know which measurements best reflect the this orthonormal basis? dynamics of our system in question.Furthermore,we some- times record more dimensions than we actually need. This question is usually a tacit assumption often overlooked. Pretend we gathered our toy example data above,but only Also,we have to deal with that pesky,real-world problem of looked at cameraA.What is an orthonormal basis for(xA,yA)? noise.In the toy example this means that we need to deal A naive choice would be {(1,0),(0,1)},but why select this with air,imperfect cameras or even friction in a less-than-ideal basis over(),(,=2)}or any other arbitrary rota- spring.Noise contaminates our data set only serving to obfus- tion?The reason is that the naive basis refects the method we cate the dynamics further.This toy example is the challenge gathered the data.Pretend we record the position (2,2).We experimenters face everyday.Keep this example in mind as we delve further into abstract concepts.Hopefully,by the end did not record2in the (direction and 0in the per- of this paper we will have a good understanding of how to pendicular direction.Rather,we recorded the position(2,2) systematically extract x using principal component analysis. on our camera meaning 2 units up and 2 units to the left in our camera window.Thus our original basis reflects the method we measured our data. Ill.FRAMEWORK:CHANGE OF BASIS How do we express this naive basis in linear algebra?In the two dimensional case,(1,0),(0,1)can be recast as individ- ual row vectors.A matrix constructed out of these row vectors The goal of principal component analysis is to identify the is the 2 x 2 identity matrix I.We can generalize this to the m- most meaningful basis to re-express a data set.The hope is dimensional case by constructing an m x m identity matrix that this new basis will filter out the noise and reveal hidden f10..01 structure.In the example of the spring,the explicit goal of b2 01.0 PCA is to determine:"the dynamics are along the x-axis."In other words,the goal of PCA is to determine that &i.e.the unit basis vector along the x-axis,is the important dimension. bm 200

2 camera A camera B camera C FIG. 1 A toy example. The position of a ball attached to an oscillat￾ing spring is recorded using three cameras A, B and C. The position of the ball tracked by each camera is depicted in each panel below. record with the cameras for several minutes. The big question remains: how do we get from this data set to a simple equation of x? We know a-priori that if we were smart experimenters, we would have just measured the position along the x-axis with one camera. But this is not what happens in the real world. We often do not know which measurements best reflect the dynamics of our system in question. Furthermore, we some￾times record more dimensions than we actually need. Also, we have to deal with that pesky, real-world problem of noise. In the toy example this means that we need to deal with air, imperfect cameras or even friction in a less-than-ideal spring. Noise contaminates our data set only serving to obfus￾cate the dynamics further. This toy example is the challenge experimenters face everyday. Keep this example in mind as we delve further into abstract concepts. Hopefully, by the end of this paper we will have a good understanding of how to systematically extract x using principal component analysis. III. FRAMEWORK: CHANGE OF BASIS The goal of principal component analysis is to identify the most meaningful basis to re-express a data set. The hope is that this new basis will filter out the noise and reveal hidden structure. In the example of the spring, the explicit goal of PCA is to determine: “the dynamics are along the x-axis.” In other words, the goal of PCA is to determine that xˆ, i.e. the unit basis vector along the x-axis, is the important dimension. Determining this fact allows an experimenter to discern which dynamics are important, redundant or noise. A. A Naive Basis With a more precise definition of our goal, we need a more precise definition of our data as well. We treat every time sample (or experimental trial) as an individual sample in our data set. At each time sample we record a set of data consist￾ing of multiple measurements (e.g. voltage, position, etc.). In our data set, at one point in time, camera A records a corre￾sponding ball position (xA,yA). One sample or trial can then be expressed as a 6 dimensional column vector ~X =        xA yA xB yB xC yC        where each camera contributes a 2-dimensional projection of the ball’s position to the entire vector ~X. If we record the ball’s position for 10 minutes at 120 Hz, then we have recorded 10× 60×120 = 72000 of these vectors. With this concrete example, let us recast this problem in ab￾stract terms. Each sample ~X is an m-dimensional vector, where m is the number of measurement types. Equivalently, every sample is a vector that lies in an m-dimensional vec￾tor space spanned by some orthonormal basis. From linear algebra we know that all measurement vectors form a linear combination of this set of unit length basis vectors. What is this orthonormal basis? This question is usually a tacit assumption often overlooked. Pretend we gathered our toy example data above, but only looked at camera A. What is an orthonormal basis for(xA,yA)? A naive choice would be {(1,0),(0,1)}, but why select this basis over {( √ 2 2 , √ 2 2 ),( − √ 2 2 , − √ 2 2 )} or any other arbitrary rota￾tion? The reason is that the naive basis reflects the method we gathered the data. Pretend we record the position (2,2). We did not record 2√ 2 in the ( √ 2 2 , √ 2 2 ) direction and 0 in the per￾pendicular direction. Rather, we recorded the position (2,2) on our camera meaning 2 units up and 2 units to the left in our camera window. Thus our original basis reflects the method we measured our data. How do we express this naive basis in linear algebra? In the two dimensional case, {(1,0),(0,1)} can be recast as individ￾ual row vectors. A matrix constructed out of these row vectors is the 2×2 identity matrix I. We can generalize this to the m￾dimensional case by constructing an m×m identity matrix B =     b1 b2 . . . bm     =     1 0 ··· 0 0 1 ··· 0 . . . . . . . . . . . . 0 0 ··· 1     = I

where each row is an orthornormal basis vector bi with m ing out the explicit dot products of PX. components.We can consider our naive basis as the effective starting point.All of our data has been recorded in this basis and thus it can be trivially expressed as a linear combination PX X1 Xn of (bi). Pm p1x1…p1X B.Change of Basis pmx1pm'xn With this rigor we may now state more precisely what PCA We can note the form of each column of Y. asks:Is there another basis,which is a linear combination of the original basis,that best re-expresses our data set? P1·X A close reader might have noticed the conspicuous addition of yi the word linear.Indeed,PCA makes one stringent but power- Pm'Xi ful assumption:linearity.Linearity vastly simplifies the prob- lem by restricting the set of potential bases.With this assump- We recognize that each coefficient of yi is a dot-product of tion PCA is now limited to re-expressing the data as a linear xi with the corresponding row in P.In other words,theh combination of its basis vectors. coefficient of yi is a projection on to the ith row of P.This is in fact the very form of an equation where yi is a projection Let X be the original data set,where each column is a single on to the basis of (p1,....Pm.Therefore,the rows of P are a sample (or moment in time)of our data set (i.e.X).In the toy new set of basis vectors for representing of columns of X. example X is an m x n matrix where m =6 and n=72000. Let Y be another m x n matrix related by a linear transfor- mation P.X is the original recorded data set and Y is a new representation of that data set. C.Questions Remaining PX=Y (1) By assuming linearity the problem reduces to finding the ap- propriate change of basis.The row vectors [p1,...,Pm}in Also let us define the following quantities. this transformation will become the principal components of X.Several questions now arise. 。pi are the rows of P What is the best way to re-express X? .xi are the columns of X (or individual X). What is a good choice of basis P? yi are the columns of Y. These questions must be answered by next asking ourselves what features we would like Y to exhibit.Evidently,addi- Equation 1 represents a change of basis and thus can have tional assumptions beyond linearity are required to arrive at a reasonable result.The selection of these assumptions is the many interpretations. subject of the next section 1.P is a matrix that transforms X into Y. IV.VARIANCE AND THE GOAL 2.Geometrically,P is a rotation and a stretch which again transforms X into Y. Now comes the most important question:what does best ex- press the data mean?This section will build up an intuitive 3.The rows of P,{p1,...,Pm},are a set of new basis vec- tors for expressing the columns of X. answer to this question and along the way tack on additional assumptions. The latter interpretation is not obvious but can be seen by writ- A.Noise and Rotation IIn this sectionand y arec vectors,but be forewamed.In all other Measurement noise in any data set must be low or else,no sections xi and yi are row vectors. matter the analysis technique,no information about a signal

3 where each row is an orthornormal basis vector bi with m components. We can consider our naive basis as the effective starting point. All of our data has been recorded in this basis and thus it can be trivially expressed as a linear combination of {bi}. B. Change of Basis With this rigor we may now state more precisely what PCA asks: Is there another basis, which is a linear combination of the original basis, that best re-expresses our data set? A close reader might have noticed the conspicuous addition of the word linear. Indeed, PCA makes one stringent but power￾ful assumption: linearity. Linearity vastly simplifies the prob￾lem by restricting the set of potential bases. With this assump￾tion PCA is now limited to re-expressing the data as a linear combination of its basis vectors. Let X be the original data set, where each column is a single sample (or moment in time) of our data set (i.e. ~X). In the toy example X is an m × n matrix where m = 6 and n = 72000. Let Y be another m × n matrix related by a linear transfor￾mation P. X is the original recorded data set and Y is a new representation of that data set. PX = Y (1) Also let us define the following quantities.1 • pi are the rows of P • xi are the columns of X (or individual ~X). • yi are the columns of Y. Equation 1 represents a change of basis and thus can have many interpretations. 1. P is a matrix that transforms X into Y. 2. Geometrically, P is a rotation and a stretch which again transforms X into Y. 3. The rows of P, {p1,...,pm}, are a set of new basis vec￾tors for expressing the columns of X. The latter interpretation is not obvious but can be seen by writ- 1 In this section xi and yi are column vectors, but be forewarned. In all other sections xi and yi are row vectors. ing out the explicit dot products of PX. PX =    p1 . . . pm    x1 ··· xn Y =    p1 · x1 ··· p1 · xn . . . . . . . . . pm · x1 ··· pm · xn    We can note the form of each column of Y. yi =    p1 · xi . . . pm · xi    We recognize that each coefficient of yi is a dot-product of xi with the corresponding row in P. In other words, the j th coefficient of yi is a projection on to the j th row of P. This is in fact the very form of an equation where yi is a projection on to the basis of {p1,...,pm}. Therefore, the rows of P are a new set of basis vectors for representing of columns of X. C. Questions Remaining By assuming linearity the problem reduces to finding the ap￾propriate change of basis. The row vectors {p1,...,pm} in this transformation will become the principal components of X. Several questions now arise. • What is the best way to re-express X? • What is a good choice of basis P? These questions must be answered by next asking ourselves what features we would like Y to exhibit. Evidently, addi￾tional assumptions beyond linearity are required to arrive at a reasonable result. The selection of these assumptions is the subject of the next section. IV. VARIANCE AND THE GOAL Now comes the most important question: what does best ex￾press the data mean? This section will build up an intuitive answer to this question and along the way tack on additional assumptions. A. Noise and Rotation Measurement noise in any data set must be low or else, no matter the analysis technique, no information about a signal

4 2 low redundancy high redundancy FIG.2 Simulated data of (x,y)for camera A.The signal and noise variances o landare graphically represented by the two FIG.3 A spectrum of possible redundancies in data from the two lines subtending the cloud of data.Note that the largest direction separate measurements rI and r2.The two measurements on the of variance does not lie along the basis of the recording (xA,yA)but left are uncorrelated because one can not predict one from the other rather along the best-fit line. Conversely,the two measurements on the right are highly correlated indicating highly redundant measurements can be extracted.There exists no absolute scale for noise but B.Redundancy rather all noise is quantified relative to the signal strength.A common measure is the signal-to-noise ratio (SNR),or a ratio of variances o-, Figure 2 hints at an additional confounding factor in our data -redundancy.This issue is particularly evident in the example of the spring.In this case multiple sensors record the same dynamic information.Reexamine Figure 2 and ask whether SNR= 6ig吧 it was really necessary to record 2 variables.Figure 3 might reflect a range of possibile plots between two arbitrary mea- surement types ri and r2.The left-hand panel depicts two A high SNR 1)indicates a high precision measurement, recordings with no apparent relationship.Because one can not while a low SNR indicates very noisy data. predict ri from r2,one says that ri and r2 are uncorrelated. Let's take a closer examination of the data from camera On the other extreme,the right-hand panel of Figure 3 de- A in Figure 2.Remembering that the spring travels in a picts highly correlated recordings.This extremity might be straight line,every individual camera should record motion in achieved by several means: a straight line as well.Therefore,any spread deviating from straight-line motion is noise.The variance due to the signal and noise are indicated by each line in the diagram.The ratio .A plot of (xA.xB)if cameras A and B are very nearby of the two lengths measures how skinny the cloud is:possibil- ities include a thin line (SNR>1),a circle (SNR =1)or even .A plot of (xA,)where x is in meters and fa is in worse.By positing reasonably good measurements,quantita- inches. tively we assume that directions with largest variances in our measurement space contain the dynamics of interest.In Fig- ure 2 the direction with the largest variance is notfa=(1,0) Clearly in the right panel of Figure 3 it would be more mean- nor y =(0,1),but the direction along the long axis of the ingful to just have recorded a single variable,not both.Why? cloud.Thus,by assumption the dynamics of interest exist Because one can calculate ri from r2 (or vice versa)using the along directions with largest variance and presumably high- best-fit line.Recording solely one response would express the est SNR data more concisely and reduce the number of sensor record- ings(2-1 variables).Indeed,this is the central idea behind Our assumption suggests that the basis for which we are dimensional reduction. searching is not the naive basis because these directions (i.e. (xA,yA))do not correspond to the directions of largest vari- ance.Maximizing the variance (and by assumption the SNR) corresponds to finding the appropriate rotation of the naive C.Covariance Matrix basis.This intuition corresponds to finding the direction indi- cated by the line in Figure 2.In the 2-dimensional case of Figure 2 the direction of largest variance corresponds to the In a 2 variable case it is simple to identify redundant cases by best-fit line for the data cloud.Thus,rotating the naive basis finding the slope of the best-fit line and judging the quality of to lie parallel to the best-fit line would reveal the direction of the fit.How do we quantify and generalize these notions to motion of the spring for the 2-D case.How do we generalize arbitrarily higher dimensions?Consider two sets of measure- this notion to an arbitrary number of dimensions?Before we ments with zero means approach this question we need to examine this issue from a second perspective. A={a1,a2,,an},B={b1,b2,,bn}

4 σ 2 signal σ 2 noise x y FIG. 2 Simulated data of (x,y) for camera A. The signal and noise variances σ 2 signal and σ 2 noise are graphically represented by the two lines subtending the cloud of data. Note that the largest direction of variance does not lie along the basis of the recording (xA,yA) but rather along the best-fit line. can be extracted. There exists no absolute scale for noise but rather all noise is quantified relative to the signal strength. A common measure is the signal-to-noise ratio (SNR), or a ratio of variances σ 2 , SNR = σ 2 signal σ 2 noise . A high SNR ( 1) indicates a high precision measurement, while a low SNR indicates very noisy data. Let’s take a closer examination of the data from camera A in Figure 2. Remembering that the spring travels in a straight line, every individual camera should record motion in a straight line as well. Therefore, any spread deviating from straight-line motion is noise. The variance due to the signal and noise are indicated by each line in the diagram. The ratio of the two lengths measures how skinny the cloud is: possibil￾ities include a thin line (SNR  1), a circle (SNR = 1) or even worse. By positing reasonably good measurements, quantita￾tively we assume that directions with largest variances in our measurement space contain the dynamics of interest. In Fig￾ure 2 the direction with the largest variance is not ˆxA = (1,0) nor ˆyA = (0,1), but the direction along the long axis of the cloud. Thus, by assumption the dynamics of interest exist along directions with largest variance and presumably high￾est SNR. Our assumption suggests that the basis for which we are searching is not the naive basis because these directions (i.e. (xA,yA)) do not correspond to the directions of largest vari￾ance. Maximizing the variance (and by assumption the SNR) corresponds to finding the appropriate rotation of the naive basis. This intuition corresponds to finding the direction indi￾cated by the line σ 2 signal in Figure 2. In the 2-dimensional case of Figure 2 the direction of largest variance corresponds to the best-fit line for the data cloud. Thus, rotating the naive basis to lie parallel to the best-fit line would reveal the direction of motion of the spring for the 2-D case. How do we generalize this notion to an arbitrary number of dimensions? Before we approach this question we need to examine this issue from a second perspective. low redundancy high redundancy r 1 r 2 r 1 r 2 r 1 r 2 FIG. 3 A spectrum of possible redundancies in data from the two separate measurements r1 and r2. The two measurements on the left are uncorrelated because one can not predict one from the other. Conversely, the two measurements on the right are highly correlated indicating highly redundant measurements. B. Redundancy Figure 2 hints at an additional confounding factor in our data - redundancy. This issue is particularly evident in the example of the spring. In this case multiple sensors record the same dynamic information. Reexamine Figure 2 and ask whether it was really necessary to record 2 variables. Figure 3 might reflect a range of possibile plots between two arbitrary mea￾surement types r1 and r2. The left-hand panel depicts two recordings with no apparent relationship. Because one can not predict r1 from r2, one says that r1 and r2 are uncorrelated. On the other extreme, the right-hand panel of Figure 3 de￾picts highly correlated recordings. This extremity might be achieved by several means: • A plot of (xA,xB) if cameras A and B are very nearby. • A plot of (xA,x˜A) where xA is in meters and ˜xA is in inches. Clearly in the right panel of Figure 3 it would be more mean￾ingful to just have recorded a single variable, not both. Why? Because one can calculate r1 from r2 (or vice versa) using the best-fit line. Recording solely one response would express the data more concisely and reduce the number of sensor record￾ings (2 → 1 variables). Indeed, this is the central idea behind dimensional reduction. C. Covariance Matrix In a 2 variable case it is simple to identify redundant cases by finding the slope of the best-fit line and judging the quality of the fit. How do we quantify and generalize these notions to arbitrarily higher dimensions? Consider two sets of measure￾ments with zero means A = {a1,a2,...,an} , B = {b1,b2,...,bn}

where the subscript denotes the sample number.The variance Consider the matrix Cx=IXXT.The ijth element of Cx of A and B are individually defined as. is the dot product between the vector of theth measurement type with the vector of the jh measurement type.We can =1∑a,哈=∑ summarize several properties of Cx: 11 The covariance between A and B is a straight-forward gener- .Cx is a square symmetric m x m matrix (Theorem 2 of alization. Appendix A) The diagonal terms of Cx are the variance of particular covariance of A and B=AB=-aibi measurement types. The off-diagonal terms of Cx are the covariance be- The covariance measures the degree of the linear relationship tween measurement types. between two variables.A large positive value indicates pos- itively correlated data.Likewise,a large negative value de- notes negatively correlated data.The absolute magnitude of Cx captures the covariance between all possible pairs of mea- surements.The covariance values reflect the noise and redun- the covariance measures the degree of redundancy.Some ad- ditional facts about the covariance. dancy in our measurements. .OAB is zero if and only if A and B are uncorrelated (e.g. In the diagonal terms,by assumption,large values cor- respond to interesting structure. Figure 2,left panel). ·OB=oifA=B. In the off-diagonal terms large magnitudes correspond to high redundancy. We can equivalently convert A and B into corresponding row Pretend we have the option of manipulating Cx.We will sug- vectors. gestively define our manipulated covariance matrix Cy.What a [al a2...an] features do we want to optimize in Cy? b =[b1 b2 ..bn] so that we may express the covariance as a dot product matrix D.Diagonalize the Covariance Matrix computation. We can summarize the last two sections by stating that our oab≡三-ab (2) goals are(1)to minimize redundancy,measured by the mag- nitude of the covariance,and (2)maximize the signal,mea- Finally,we can generalize from two vectors to an arbitrary sured by the variance.What would the optimized covariance matrix Cy look like? number.Rename the row vectors a and b as x and x2,respec- tively,and consider additional indexed row vectors X3,...,Xm Define a new m x n matrix X .All off-diagonal terms in Cy should be zero.Thus,Cy must be a diagonal matrix.Or,said another way,Y is decorrelated. Each successive dimension in Y should be rank-ordered according to variance. One interpretation of X is the following.Each row of X corre- There are many methods for diagonalizing Cy.It is curious to sponds to all measurements of a particular type.Each column note that PCA arguably selects the easiest method:PCA as- of X corresponds to a set of measurements from one particular trial (this is X from section 3.1).We now arrive at a definition sumes that all basis vectors [p,...,Pm}are orthonormal,i.e. P is an orthonormal matrix.Why is this assumption easiest? for the covariance matrix Cx. Envision how PCA works.In our simple example in Figure 2, Cx≡-XXT P acts as a generalized rotation to align a basis with the axis n of maximal variance.In multiple dimensions this could be performed by a simple algorithm: 2 Note that in practice,the covariance is calculated asThe 1.Select a normalized direction in m-dimensional space slight change in normalization constant arises from estimation theory.but along which the variance in X is maximized.Save this that is beyond the scope of this tutorial. vector as p1

5 where the subscript denotes the sample number. The variance of A and B are individually defined as, σ 2 A = 1 n ∑ i a 2 i , σ 2 B = 1 n ∑ i b 2 i The covariance between A and B is a straight-forward gener￾alization. covariance o f A and B ≡ σ 2 AB = 1 n ∑ i aibi The covariance measures the degree of the linear relationship between two variables. A large positive value indicates pos￾itively correlated data. Likewise, a large negative value de￾notes negatively correlated data. The absolute magnitude of the covariance measures the degree of redundancy. Some ad￾ditional facts about the covariance. • σAB is zero if and only if A and B are uncorrelated (e.g. Figure 2, left panel). • σ 2 AB = σ 2 A if A = B. We can equivalently convert A and B into corresponding row vectors. a = [a1 a2 ... an] b = [b1 b2 ... bn] so that we may express the covariance as a dot product matrix computation.2 σ 2 ab ≡ 1 n abT (2) Finally, we can generalize from two vectors to an arbitrary number. Rename the row vectors a and b as x1 and x2, respec￾tively, and consider additional indexed row vectors x3,...,xm. Define a new m×n matrix X. X =    x1 . . . xm    One interpretation of X is the following. Each row of X corre￾sponds to all measurements of a particular type. Each column of X corresponds to a set of measurements from one particular trial (this is ~X from section 3.1). We now arrive at a definition for the covariance matrix CX. CX ≡ 1 n XXT . 2 Note that in practice, the covariance σ 2 AB is calculated as 1 n−1 ∑i aibi . The slight change in normalization constant arises from estimation theory, but that is beyond the scope of this tutorial. Consider the matrix CX = 1 nXXT . The i jth element of CX is the dot product between the vector of the i th measurement type with the vector of the j th measurement type. We can summarize several properties of CX: • CX is a square symmetric m×m matrix (Theorem 2 of Appendix A) • The diagonal terms of CX are the variance of particular measurement types. • The off-diagonal terms of CX are the covariance be￾tween measurement types. CX captures the covariance between all possible pairs of mea￾surements. The covariance values reflect the noise and redun￾dancy in our measurements. • In the diagonal terms, by assumption, large values cor￾respond to interesting structure. • In the off-diagonal terms large magnitudes correspond to high redundancy. Pretend we have the option of manipulating CX. We will sug￾gestively define our manipulated covariance matrix CY. What features do we want to optimize in CY? D. Diagonalize the Covariance Matrix We can summarize the last two sections by stating that our goals are (1) to minimize redundancy, measured by the mag￾nitude of the covariance, and (2) maximize the signal, mea￾sured by the variance. What would the optimized covariance matrix CY look like? • All off-diagonal terms in CY should be zero. Thus, CY must be a diagonal matrix. Or, said another way, Y is decorrelated. • Each successive dimension in Y should be rank-ordered according to variance. There are many methods for diagonalizing CY. It is curious to note that PCA arguably selects the easiest method: PCA as￾sumes that all basis vectors {p1,...,pm} are orthonormal, i.e. P is an orthonormal matrix. Why is this assumption easiest? Envision how PCA works. In our simple example in Figure 2, P acts as a generalized rotation to align a basis with the axis of maximal variance. In multiple dimensions this could be performed by a simple algorithm: 1. Select a normalized direction in m-dimensional space along which the variance in X is maximized. Save this vector as p1

6 2.Find another direction along which variance is maxi- V.SOLVING PCA USING EIGENVECTOR DECOMPOSITION mized,however,because of the orthonormality condi- tion,restrict the search to all directions orthogonal to We derive our first algebraic solution to PCA based on an im- all previous selected directions.Save this vector as pi portant property of eigenvector decomposition.Once again 3.Repeat this procedure until m vectors are selected the data set is X,an m x n matrix,where m is the number of measurement types and n is the number of samples.The goal is summarized as follows The resulting ordered set of p's are the principal components. In principle this simple algorithm works,however that would Find some orthonormal matrix P in Y=PX such bely the true reason why the orthonormality assumption is ju- that Cy=YYT is a diagonal matrix.The rows dicious.The true benefit to this assumption is that there exists of P are the principal components of X. an efficient,analytical solution to this problem.We will dis- cuss two solutions in the following sections We begin by rewriting Cy in terms of the unknown variable Notice what we gained with the stipulation of rank-ordered 1 variance.We have a method for judging the importance of Cy =-YYT n the principal direction.Namely,the variances associated with 1 each direction Pi quantify how "principal"each direction is =(PX)(PX)T 1 by rank-ordering each basis vector pi according to the corre- sponding variances.We will now pause to review the implica- =-PXXTPT 1 tions of all the assumptions made to arrive at this mathemati- cal goal. =P(-XXT)PT Cy PCxPT E.Summary of Assumptions Note that we have identified the covariance matrix of X in the last line. This section provides a summary of the assumptions be- Our plan is to recognize that any symmetric matrix A is diag- hind PCA and hint at when these assumptions might perform onalized by an orthogonal matrix of its eigenvectors (by The- poorly. orems 3 and 4 from Appendix A).For a symmetric matrix A Theorem 4 provides A=EDE,where D is a diagonal matrix and E is a matrix of eigenvectors of A arranged as columns.3 I.Linearity Linearity frames the problem as a change of ba- Now comes the trick.We select the matrix P to be a matrix sis.Several areas of research have explored how where each row pi is an eigenvector of IXXT.By this selec- extending these notions to nonlinear regimes (see tion,P=ET.With this relation and Theorem 1 of Appendix Discussion). A (P-1 =PT)we can finish evaluating Cy. II.Large variances have important structure. Cy PCxP7 This assumption also encompasses the belief that =P(ETDE)PT the data has a high SNR.Hence,principal compo- =P(PTDP)PT nents with larger associated variances represent =(PP)D(PP) interesting structure,while those with lower vari- ances represent noise.Note that this is a strong, =(PP-1)D(PP-1) and sometimes,incorrect assumption (see Dis- Cy D cussion). It is evident that the choice of P diagonalizes Cy.This was III.The principal components are orthogonal. the goal for PCA.We can summarize the results of PCA in the This assumption provides an intuitive simplifica- matrices P and Cy. tion that makes PCA soluble with linear algebra decomposition techniques.These techniques are highlighted in the two following sections. 3 The matrix A might have r<m orthonormal eigenvectors where r is the rank of the matrix.When the rank of A is less than m,A is degenerate or all We have discussed all aspects of deriving PCA-what remain data occupy a subspace of dimension r<m.Maintaining the constraint of are the linear algebra solutions.The first solution is some- orthogonality,we can remedy this situation by selecting (m-r)additional orthonormal vectors to "fill up"the matrix E.These additional vectors what straightforward while the second solution involves un- do not effect the final solution because the variances associated with these derstanding an important algebraic decomposition. directions are zero

6 2. Find another direction along which variance is maxi￾mized, however, because of the orthonormality condi￾tion, restrict the search to all directions orthogonal to all previous selected directions. Save this vector as pi 3. Repeat this procedure until m vectors are selected. The resulting ordered set of p’s are the principal components. In principle this simple algorithm works, however that would bely the true reason why the orthonormality assumption is ju￾dicious. The true benefit to this assumption is that there exists an efficient, analytical solution to this problem. We will dis￾cuss two solutions in the following sections. Notice what we gained with the stipulation of rank-ordered variance. We have a method for judging the importance of the principal direction. Namely, the variances associated with each direction pi quantify how “principal” each direction is by rank-ordering each basis vector pi according to the corre￾sponding variances.We will now pause to review the implica￾tions of all the assumptions made to arrive at this mathemati￾cal goal. E. Summary of Assumptions This section provides a summary of the assumptions be￾hind PCA and hint at when these assumptions might perform poorly. I. Linearity Linearity frames the problem as a change of ba￾sis. Several areas of research have explored how extending these notions to nonlinear regimes (see Discussion). II. Large variances have important structure. This assumption also encompasses the belief that the data has a high SNR. Hence, principal compo￾nents with larger associated variances represent interesting structure, while those with lower vari￾ances represent noise. Note that this is a strong, and sometimes, incorrect assumption (see Dis￾cussion). III. The principal components are orthogonal. This assumption provides an intuitive simplifica￾tion that makes PCA soluble with linear algebra decomposition techniques. These techniques are highlighted in the two following sections. We have discussed all aspects of deriving PCA - what remain are the linear algebra solutions. The first solution is some￾what straightforward while the second solution involves un￾derstanding an important algebraic decomposition. V. SOLVING PCA USING EIGENVECTOR DECOMPOSITION We derive our first algebraic solution to PCA based on an im￾portant property of eigenvector decomposition. Once again, the data set is X, an m × n matrix, where m is the number of measurement types and n is the number of samples. The goal is summarized as follows. Find some orthonormal matrix P in Y = PX such that CY ≡ 1 nYYT is a diagonal matrix. The rows of P are the principal components of X. We begin by rewriting CY in terms of the unknown variable. CY = 1 n YYT = 1 n (PX)(PX) T = 1 n PXXTP T = P( 1 n XXT )P T CY = PCXP T Note that we have identified the covariance matrix of X in the last line. Our plan is to recognize that any symmetric matrix A is diag￾onalized by an orthogonal matrix of its eigenvectors (by The￾orems 3 and 4 from Appendix A). For a symmetric matrix A Theorem 4 provides A = EDET , where D is a diagonal matrix and E is a matrix of eigenvectors of A arranged as columns.3 Now comes the trick. We select the matrix P to be a matrix where each row pi is an eigenvector of 1 nXXT . By this selec￾tion, P ≡ E T. With this relation and Theorem 1 of Appendix A (P −1 = P T ) we can finish evaluating CY. CY = PCXP T = P(E TDE)P T = P(P TDP)P T = (PPT )D(PPT ) = (PP−1 )D(PP−1 ) CY = D It is evident that the choice of P diagonalizes CY. This was the goal for PCA. We can summarize the results of PCA in the matrices P and CY. 3 The matrix A might have r ≤ m orthonormal eigenvectors where r is the rank of the matrix. When the rank of A is less than m, A is degenerate or all data occupy a subspace of dimension r ≤ m. Maintaining the constraint of orthogonality, we can remedy this situation by selecting (m−r) additional orthonormal vectors to “fill up” the matrix E. These additional vectors do not effect the final solution because the variances associated with these directions are zero

1 The principal components of X are the eigenvectors of ·Xll=o Cx=IXXT These properties are both proven in Theorem 5.We now have .Theh diagonal value of Cy is the variance of X along all of the pieces to construct the decomposition.The scalar Pi. version of singular value decomposition is just a restatement of the third definition. In practice computing PCA of a data set X entails (1)subtract- X0:=oǘ; (3) ing off the mean of each measurement type and(2)computing the eigenvectors of Cx.This solution is demonstrated in Mat- This result says a quite a bit.X multiplied by an eigen- lab code included in Appendix B. vector of XTX is equal to a scalar times another vector. The set of eigenvectors ,2,...}and the set of vec- tors [i,d2,...,r}are both orthonormal sets or bases in r- dimensional space. VI.A MORE GENERAL SOLUTION USING SVD We can summarize this result for all vectors in one matrix multiplication by following the prescribed construction in Fig- This section is the most mathematically involved and can be ure 4.We start by constructing a new diagonal matrix E. skipped without much loss of continuity.It is presented solely for completeness.We derive another algebraic solution for PCA and in the process,find that PCA is closely related to singular value decomposition (SVD).In fact,the two are so intimately related that the names are often used interchange- 》三 0 ably.What we will see though is that SVD is a more general method of understanding change of basis. We begin by quickly deriving the decomposition.In the fol- 0 lowing section we interpret the decomposition and in the last where or≥oz≥..≥or are the rank-ordered set of singu section we relate these results to PCA. lar values.Likewise we construct accompanying orthogonal matrices, V=[12.m A.Singular Value Decomposition U=dd...da Let X be an arbitrary n x m matrix4 and XTX be a rank r, where we have appended an additional(m-r)and(n-r)or- thonormal vectors to"fill up"the matrices for V and U respec- square,symmetric m x m matrix.In a seemingly unmotivated tively (i.e.to deal with degeneracy issues).Figure 4 provides fashion,let us define all of the quantities of interest. a graphical representation of how all of the pieces fit together to form the matrix version of SVD. 1,V2,...,v is the set of orthonormal m x 1 eigen- XV=UZ vectors with associated eigenvalues ,2,...,for the symmetric matrix X7X. where each column of V and U perform the scalar version of the decomposition(Equation 3).Because V is orthogonal,we (XTX):=λ, can multiply both sides by V-1-VT to arrive at the final form of the decomposition. ·oi≡√入iare positive real and termed the singular val-. X=UZVT (4) ues. Although derived without motivation,this decomposition is .[d2,...,f}is the set of n x 1 vectors defined by quite powerful.Equation 4 states that any arbitrary matrix X d三X1, can be converted to an orthogonal matrix,a diagonal matrix and another orthogonal matrix (or a rotation,a stretch and a The final definition includes two new and unexpected proper- second rotation).Making sense of Equation 4 is the subject of the next section. ties. 1 ifi=i 0 otherwise B.Interpreting SVD The final form of SVD is a concise but thick statement.In- stead let us reinterpret Equation 3 as 4 Notice that in this section only we are reversing convention frommnto nx m.The reason for this derivation will become clear in section 6.3. Xa=kb

7 • The principal components of X are the eigenvectors of CX = 1 nXXT . • The i th diagonal value of CY is the variance of X along pi . In practice computing PCA of a data set X entails (1) subtract￾ing off the mean of each measurement type and (2) computing the eigenvectors of CX. This solution is demonstrated in Mat￾lab code included in Appendix B. VI. A MORE GENERAL SOLUTION USING SVD This section is the most mathematically involved and can be skipped without much loss of continuity. It is presented solely for completeness. We derive another algebraic solution for PCA and in the process, find that PCA is closely related to singular value decomposition (SVD). In fact, the two are so intimately related that the names are often used interchange￾ably. What we will see though is that SVD is a more general method of understanding change of basis. We begin by quickly deriving the decomposition. In the fol￾lowing section we interpret the decomposition and in the last section we relate these results to PCA. A. Singular Value Decomposition Let X be an arbitrary n × m matrix4 and X TX be a rank r, square, symmetric m×m matrix. In a seemingly unmotivated fashion, let us define all of the quantities of interest. • {vˆ1,vˆ2,...,vˆr} is the set of orthonormal m × 1 eigen￾vectors with associated eigenvalues {λ1,λ2,...,λr} for the symmetric matrix X TX. (X TX)vˆi = λivˆi • σi ≡ √ λi are positive real and termed the singular val￾ues. • {uˆ 1,uˆ 2,...,uˆr} is the set of n × 1 vectors defined by uˆi ≡ 1 σi Xvˆi . The final definition includes two new and unexpected proper￾ties. • uˆi ·uˆj =  1 if i = j 0 otherwise 4 Notice that in this section only we are reversing convention from m×n to n×m. The reason for this derivation will become clear in section 6.3. • kXvˆik = σi These properties are both proven in Theorem 5. We now have all of the pieces to construct the decomposition. The scalar version of singular value decomposition is just a restatement of the third definition. Xvˆi = σiuˆi (3) This result says a quite a bit. X multiplied by an eigen￾vector of X TX is equal to a scalar times another vector. The set of eigenvectors {vˆ1,vˆ2,...,vˆr} and the set of vec￾tors {uˆ 1,uˆ 2,...,uˆr} are both orthonormal sets or bases in r￾dimensional space. We can summarize this result for all vectors in one matrix multiplication by following the prescribed construction in Fig￾ure 4. We start by constructing a new diagonal matrix Σ. Σ ≡           σ1˜ . . . 0 σr˜ 0 0 . . . 0           where σ1˜ ≥ σ2˜ ≥ ... ≥ σr˜ are the rank-ordered set of singu￾lar values. Likewise we construct accompanying orthogonal matrices, V = vˆ 1˜ vˆ 2˜ ... vˆm˜ U = uˆ 1˜ uˆ 2˜ ... uˆ n˜ where we have appended an additional (m−r) and (n−r) or￾thonormal vectors to “fill up” the matrices for V and U respec￾tively (i.e. to deal with degeneracy issues). Figure 4 provides a graphical representation of how all of the pieces fit together to form the matrix version of SVD. XV = UΣ where each column of V and U perform the scalar version of the decomposition (Equation 3). Because V is orthogonal, we can multiply both sides by V −1 = V T to arrive at the final form of the decomposition. X = UΣV T (4) Although derived without motivation, this decomposition is quite powerful. Equation 4 states that any arbitrary matrix X can be converted to an orthogonal matrix, a diagonal matrix and another orthogonal matrix (or a rotation, a stretch and a second rotation). Making sense of Equation 4 is the subject of the next section. B. Interpreting SVD The final form of SVD is a concise but thick statement. In￾stead let us reinterpret Equation 3 as Xa = kb

8 The scalar form of SVD is expressed in equation 3. XVi=oidi The mathematical intuition behind the construction of the matrix form is that we want to express all n scalar equations in just one equation.It is easiest to understand this process graphically.Drawing the matrices of equation 3 looks likes the following. m positive m We can construct three new matrices V,U and E.All singular values are first rank-ordered >..>or,and the corre sponding vectors are indexed in the same rank order.Each pair of associated vectors and is stacked in the column along their respective matrices.The corresponding singular value o;is placed along the diagonal(theh position)of This generates the equation XV UE,which looks like the following. nx m The matrices V and U are mx m and nxn matrices respectively and is a diagonal matrix with a few non-zero values(repre- sented by the checkerboard)along its diagonal.Solving this single matrix equation solves all n"value"form equations. FIG.4 Construction of the matrix form of SVD(Equation 4)from the scalar form(Equation 3). where a and b are column vectors and k is a scalar con- There is a funny symmetry to SVD such that we can define a stant.The set 1,72,...,m}is analogous to a and the set similar quantity -the row space. {2,...n}is analogous to b.What is unique though is that 1,v2,....m}and [,d2,...,fin}are orthonormal sets XV=ZU of vectors which span an m or n dimensional space,respec- tively.In particular,loosely speaking these sets appear to span (xv)7 (ZU) all possible“inputs”(i.e.a)and“outputs”(i.e.b).Can we VIXT =UE formalize the view that (1,v2....,n}and [a,d2,...n} VTXT=L span all possible"inputs'”and“outputs'"? We can manipulate Equation 4 to make this fuzzy hypothesis where we have defined Z=UTE.Again the rows of VT (or more precise. the columns of V)are an orthonormal basis for transforming XT into Z.Because of the transpose on X,it follows that V X UEVT is an orthonormal basis spanning the row space of X.The UTX EVT row space likewise formalizes the notion of what are possible “inputs”into an arbitrary matrix. UX=Z We are only scratching the surface for understanding the full where we have defined Z=EVT.Note that the previous implications of SVD.For the purposes of this tutorial though, columns {d2,...,n}are now rows in U.Comparing this we have enough information to understand how PCA will fall equation to Equation 1,2,...,in perform the same role within this framework. as (1,p2.....fm}.Hence,U is a change of basis from X to Z.Just as before,we were transforming column vectors,we can again infer that we are transforming column vectors.The fact that the orthonormal basis UT(or P)transforms column vectors means that UT is a basis that spans the columns of X. C.SVD and PCA Bases that span the columns are termed the column space of X.The column space formalizes the notion of what are the It is evident that PCA and SVD are intimately related.Let us possible“outputs”of any matrix.. return to the original m x n data matrix X.We can define a

8 The scalar form of SVD is expressed in equation 3. Xvˆi = σiuˆi The mathematical intuition behind the construction of the matrix form is that we want to express all n scalar equations in just one equation. It is easiest to understand this process graphically. Drawing the matrices of equation 3 looks likes the following. We can construct three new matrices V, U and Σ. All singular values are first rank-ordered σ1˜ ≥ σ2˜ ≥ ... ≥ σr˜ , and the corre￾sponding vectors are indexed in the same rank order. Each pair of associated vectors vˆi and uˆi is stacked in the i th column along their respective matrices. The corresponding singular value σi is placed along the diagonal (the iith position) of Σ. This generates the equation XV = UΣ, which looks like the following. The matrices V and U are m×m and n×n matrices respectively and Σ is a diagonal matrix with a few non-zero values (repre￾sented by the checkerboard) along its diagonal. Solving this single matrix equation solves all n “value” form equations. FIG. 4 Construction of the matrix form of SVD (Equation 4) from the scalar form (Equation 3). where a and b are column vectors and k is a scalar con￾stant. The set {vˆ1,vˆ2,...,vˆm} is analogous to a and the set {uˆ 1,uˆ 2,...,uˆ n} is analogous to b. What is unique though is that {vˆ1,vˆ2,...,vˆm} and {uˆ 1,uˆ 2,...,uˆ n} are orthonormal sets of vectors which span an m or n dimensional space, respec￾tively. In particular, loosely speaking these sets appear to span all possible “inputs” (i.e. a) and “outputs” (i.e. b). Can we formalize the view that {vˆ1,vˆ2,...,vˆn} and {uˆ 1,uˆ 2,...,uˆ n} span all possible “inputs” and “outputs”? We can manipulate Equation 4 to make this fuzzy hypothesis more precise. X = UΣV T U TX = ΣV T U TX = Z where we have defined Z ≡ ΣV T . Note that the previous columns {uˆ 1,uˆ 2,...,uˆ n} are now rows in U T . Comparing this equation to Equation 1, {uˆ 1,uˆ 2,...,uˆ n} perform the same role as {pˆ 1,pˆ 2,...,pˆ m}. Hence, U T is a change of basis from X to Z. Just as before, we were transforming column vectors, we can again infer that we are transforming column vectors. The fact that the orthonormal basis U T (or P) transforms column vectors means that U T is a basis that spans the columns of X. Bases that span the columns are termed the column space of X. The column space formalizes the notion of what are the possible “outputs” of any matrix. There is a funny symmetry to SVD such that we can define a similar quantity - the row space. XV = ΣU (XV) T = (ΣU) T V TX T = U TΣ V TX T = Z where we have defined Z ≡ U TΣ. Again the rows of V T (or the columns of V) are an orthonormal basis for transforming X T into Z. Because of the transpose on X, it follows that V is an orthonormal basis spanning the row space of X. The row space likewise formalizes the notion of what are possible “inputs” into an arbitrary matrix. We are only scratching the surface for understanding the full implications of SVD. For the purposes of this tutorial though, we have enough information to understand how PCA will fall within this framework. C. SVD and PCA It is evident that PCA and SVD are intimately related. Let us return to the original m × n data matrix X. We can define a

Quick Summary of PCA 1.Organize data as an m x n matrix,where m is the number of measurement types and n is the number of samples. 2.Subtract off the mean for each measurement type. 3.Calculate the SVD or the eigenvectors of the covariance. FIG.5 A step-by-step instruction list on how to perform principal component analysis new matrix Y as an n x m matrix.5 FIG.6 Example of when PCA fails (red lines).(a)Tracking a per- 1 son on a ferris wheel (black dots).All dynamics can be described by the phase of the wheel 0.a non-linear combination of the naive Vn basis.(b)In this example data set,non-Gaussian distributed data and non-orthogonal axes causes PCA to fail.The axes with the largest where each column of Y has zero mean.The choice of Y becomes clear by analyzing YTY. variance do not correspond to the appropriate answer. =(x)'(x principle component provides a means for comparing the rel- ative importance of each dimension.An implicit hope behind x employing this method is that the variance along a small num- ber of principal components(i.e.less than the number of mea- YTY =Cx surement types)provides a reasonable characterization of the complete data set.This statement is the precise intuition be- By construction YTY equals the covariance matrix of X.From hind any method of dimensional reduction-a vast arena of section 5 we know that the principal components of X are active research.In the example of the spring,PCA identi- the eigenvectors of Cx.If we calculate the SVD of Y,the fies that a majority of variation exists along a single dimen- columns of matrix V contain the eigenvectors of YTY=Cx. sion(the direction of motion &)eventhough 6 dimensions are Therefore,the columns of V are the principal components of recorded. X.This second algorithm is encapsulated in Matlab code in- cluded in Appendix B. Although PCA "works"on a multitude of real world prob- lems,any diligent scientist or engineer must ask when does What does this mean?V spans the row space of Y PCA fail?Before we answer this question,let us note a re- Therefore,V must also span the column space of.We markable feature of this algorithm.PCA is completely non- can conclude that finding the principal components amounts parametric:any data set can be plugged in and an answer comes out,requiring no parameters to tweak and no regard for to finding an orthonormal basis that spans the column space of X.6 how the data was recorded.From one perspective,the fact that PCA is non-parametric(or plug-and-play)can be considered a positive feature because the answer is unique and indepen- dent of the user.From another perspective the fact that PCA VIl.DISCUSSION is agnostic to the source of the data is also a weakness.For instance,consider tracking a person on a ferris wheel in Fig- ure 6a.The data points can be cleanly described by a single Principal component analysis(PCA)has widespread applica- tions because it reveals simple underlying structures in com- variable,the precession angle of the wheel 0,however PCA would fail to recover this variable. plex data sets using analytical solutions from linear algebra. Figure 5 provides a brief summary for implementing PCA. A primary benefit of PCA arises from quantifying the impor- tance of each dimension for describing the variability of a data A.Limits and Statistics of Dimensional Reduction set.In particular,the measurement of the variance along each A deeper appreciation of the limits of PCA requires some con- sideration about the underlying assumptions and in tandem, a more rigorous description of the source of data.Gener 5Yis of the appropriatendimensions laid out in the derivation of section ally speaking,the primary motivation behind this method is 6.1.This is the reason for the "flipping"of dimensions in 6.1 and Figure 4. 6 If the final goal is to find an orthonormal basis for the coulmn space of to decorrelate the data set,i.e.remove second-order depen- X then we can calculate it directly without constructing Y.By symmetry dencies.The manner of approaching this goal is loosely akin the columns of U produced by the SVD ofX must also be the principal to how one might explore a town in the Western United States: components. drive down the longest road running through the town.When

9 Quick Summary of PCA 1. Organize data as an m×n matrix, where m is the number of measurement types and n is the number of samples. 2. Subtract off the mean for each measurement type. 3. Calculate the SVD or the eigenvectors of the covariance. FIG. 5 A step-by-step instruction list on how to perform principal component analysis new matrix Y as an n×m matrix.5 Y ≡ 1 √ n X T where each column of Y has zero mean. The choice of Y becomes clear by analyzing Y TY. Y TY =  1 √ n X T T  1 √ n X T  = 1 n XXT Y TY = CX By construction Y TY equals the covariance matrix of X. From section 5 we know that the principal components of X are the eigenvectors of CX. If we calculate the SVD of Y, the columns of matrix V contain the eigenvectors of Y TY = CX. Therefore, the columns of V are the principal components of X. This second algorithm is encapsulated in Matlab code in￾cluded in Appendix B. What does this mean? V spans the row space of Y ≡ √ 1 n X T . Therefore, V must also span the column space of √ 1 n X. We can conclude that finding the principal components amounts to finding an orthonormal basis that spans the column space of X. 6 VII. DISCUSSION Principal component analysis (PCA) has widespread applica￾tions because it reveals simple underlying structures in com￾plex data sets using analytical solutions from linear algebra. Figure 5 provides a brief summary for implementing PCA. A primary benefit of PCA arises from quantifying the impor￾tance of each dimension for describing the variability of a data set. In particular, the measurement of the variance along each 5 Y is of the appropriate n×m dimensions laid out in the derivation of section 6.1. This is the reason for the “flipping” of dimensions in 6.1 and Figure 4. 6 If the final goal is to find an orthonormal basis for the coulmn space of X then we can calculate it directly without constructing Y. By symmetry the columns of U produced by the SVD of √1 n X must also be the principal components. A B x y x y z θ FIG. 6 Example of when PCA fails (red lines). (a) Tracking a per￾son on a ferris wheel (black dots). All dynamics can be described by the phase of the wheel θ, a non-linear combination of the naive basis. (b) In this example data set, non-Gaussian distributed data and non-orthogonal axes causes PCA to fail. The axes with the largest variance do not correspond to the appropriate answer. principle component provides a means for comparing the rel￾ative importance of each dimension. An implicit hope behind employing this method is that the variance along a small num￾ber of principal components (i.e. less than the number of mea￾surement types) provides a reasonable characterization of the complete data set. This statement is the precise intuition be￾hind any method of dimensional reduction – a vast arena of active research. In the example of the spring, PCA identi- fies that a majority of variation exists along a single dimen￾sion (the direction of motion xˆ), eventhough 6 dimensions are recorded. Although PCA “works” on a multitude of real world prob￾lems, any diligent scientist or engineer must ask when does PCA fail? Before we answer this question, let us note a re￾markable feature of this algorithm. PCA is completely non￾parametric: any data set can be plugged in and an answer comes out, requiring no parameters to tweak and no regard for how the data was recorded. From one perspective, the fact that PCA is non-parametric (or plug-and-play) can be considered a positive feature because the answer is unique and indepen￾dent of the user. From another perspective the fact that PCA is agnostic to the source of the data is also a weakness. For instance, consider tracking a person on a ferris wheel in Fig￾ure 6a. The data points can be cleanly described by a single variable, the precession angle of the wheel θ, however PCA would fail to recover this variable. A. Limits and Statistics of Dimensional Reduction A deeper appreciation of the limits of PCA requires some con￾sideration about the underlying assumptions and in tandem, a more rigorous description of the source of data. Gener￾ally speaking, the primary motivation behind this method is to decorrelate the data set, i.e. remove second-order depen￾dencies. The manner of approaching this goal is loosely akin to how one might explore a town in the Western United States: drive down the longest road running through the town. When

10 one sees another big road,turn left or right and drive down APPENDIX A:Linear Algebra this road,and so forth.In this analogy,PCA requires that each new road explored must be perpendicular to the previous,but clearly this requirement is overly stringent and the data (or This section proves a few unapparent theorems in linear town)might be arranged along non-orthogonal axes,such as algebra,which are crucial to this paper. Figure 6b.Figure 6 provides two examples of this type of data where PCA provides unsatisfying results 1.The inverse of an orthogonal matrix is its transpose. To address these problems,we must define what we consider optimal results.In the context of dimensional reduction,one Let A be an m x n orthogonal matrix where a;is the ith column measure of success is the degree to which a reduced repre- vector.The ijth element of ATA is sentation can predict the original data.In statistical terms, we must define an error function (or loss function).It can (ATA)万=a到= ∫1fi=j be proved that under a common loss function,mean squared 0 otherwise error (i.e.L2 norm),PCA provides the optimal reduced rep resentation of the data.This means that selecting orthogonal Therefore,because ATA=I,it follows that A-1=AT. directions for principal components is the best solution to pre- dicting the original data.Given the examples of Figure 6,how could this statement be true?Our intuitions from Figure 6 2.For any matrix A,ATA and AAT are symmetric. suggest that this result is somehow misleading. The solution to this paradox lies in the goal we selected for the (AAT)T -ATTAT-AAT analysis.The goal of the analysis is to decorrelate the data,or (ATA)T=ATATT-ATA said in other terms,the goal is to remove second-order depen- dencies in the data.In the data sets of Figure 6,higher order 3.A matrix is symmetric if and only if it is orthogonally dependencies exist between the variables.Therefore,remov- diagonalizable. ing second-order dependencies is insufficient at revealing all structure in the data. Because this statement is bi-directional,it requires a two-part Multiple solutions exist for removing higher-order dependen- "if-and-only-if"proof.One needs to prove the forward and cies.For instance,if prior knowledge is known about the the backwards“if-then”cases. problem,then a nonlinearity (i.e.kernel)might be applied Let us start with the forward case.If A is orthogonally di- to the data to transform the data to a more appropriate naive agonalizable,then A is a symmetric matrix.By hypothesis basis.For instance,in Figure 6a,one might examine the po- orthogonally diagonalizable means that there exists some E lar coordinate representation of the data.This parametric ap- such that A =EDET,where D is a diagonal matrix and E is proach is often termed kernel PCA. some special matrix which diagonalizes A.Let us compute Another direction is to impose more general statistical defini- tions of dependency within a data set,e.g.requiring that data AT =(EDET)T =ETTDTET =EDET =A along reduced dimensions be statistically independent.This class of algorithms,termed,independent component analysis (ICA),has been demonstrated to succeed in many domains Evidently,if A is orthogonally diagonalizable,it must also be where PCA fails.ICA has been applied to many areas of sig- symmetric. nal and image processing,but suffers from the fact that solu- The reverse case is more involved and less clean so it will be tions are (sometimes)difficult to compute. left to the reader.In lieu of this,hopefully the "forward"case Writing this paper has been an extremely instructional expe- is suggestive if not somewhat convincing. rience for me.I hope that this paper helps to demystify the motivation and results of PCA,and the underlying assump- 4.A symmetric matrix is diagonalized by a matrix of its tions behind this important analysis technique.Please send orthonormal eigenvectors. me a note if this has been useful to you as it inspires me to keep writing! Let A be a square nx n symmetric matrix with associated eigenvectors [ei,e2,...,en}.Let E=[ei e2...en]where the th column of Eis the eigenvector ei.This theorem asserts that 7 When are second order dependencies sufficient for revealing all dependen- there exists a diagonal matrix D such that A =EDET cies in a data set?This statistical condition is met when the first and second order statistics are sufficient statistics of the data.This occurs,for instance, This proof is in two parts.In the first part,we see that the when a data set is Gaussian distributed. any matrix can be orthogonally diagonalized if and only if it that matrix's eigenvectors are all linearly independent.In the second part of the proof,we see that a symmetric matrix

10 one sees another big road, turn left or right and drive down this road, and so forth. In this analogy, PCA requires that each new road explored must be perpendicular to the previous, but clearly this requirement is overly stringent and the data (or town) might be arranged along non-orthogonal axes, such as Figure 6b. Figure 6 provides two examples of this type of data where PCA provides unsatisfying results. To address these problems, we must define what we consider optimal results. In the context of dimensional reduction, one measure of success is the degree to which a reduced repre￾sentation can predict the original data. In statistical terms, we must define an error function (or loss function). It can be proved that under a common loss function, mean squared error (i.e. L2 norm), PCA provides the optimal reduced rep￾resentation of the data. This means that selecting orthogonal directions for principal components is the best solution to pre￾dicting the original data. Given the examples of Figure 6, how could this statement be true? Our intuitions from Figure 6 suggest that this result is somehow misleading. The solution to this paradox lies in the goal we selected for the analysis. The goal of the analysis is to decorrelate the data, or said in other terms, the goal is to remove second-order depen￾dencies in the data. In the data sets of Figure 6, higher order dependencies exist between the variables. Therefore, remov￾ing second-order dependencies is insufficient at revealing all structure in the data.7 Multiple solutions exist for removing higher-order dependen￾cies. For instance, if prior knowledge is known about the problem, then a nonlinearity (i.e. kernel) might be applied to the data to transform the data to a more appropriate naive basis. For instance, in Figure 6a, one might examine the po￾lar coordinate representation of the data. This parametric ap￾proach is often termed kernel PCA. Another direction is to impose more general statistical defini￾tions of dependency within a data set, e.g. requiring that data along reduced dimensions be statistically independent. This class of algorithms, termed, independent component analysis (ICA), has been demonstrated to succeed in many domains where PCA fails. ICA has been applied to many areas of sig￾nal and image processing, but suffers from the fact that solu￾tions are (sometimes) difficult to compute. Writing this paper has been an extremely instructional expe￾rience for me. I hope that this paper helps to demystify the motivation and results of PCA, and the underlying assump￾tions behind this important analysis technique. Please send me a note if this has been useful to you as it inspires me to keep writing! 7 When are second order dependencies sufficient for revealing all dependen￾cies in a data set? This statistical condition is met when the first and second order statistics are sufficient statistics of the data. This occurs, for instance, when a data set is Gaussian distributed. APPENDIX A: Linear Algebra This section proves a few unapparent theorems in linear algebra, which are crucial to this paper. 1. The inverse of an orthogonal matrix is its transpose. Let A be an m×n orthogonal matrix where ai is the i th column vector. The i jth element of A TA is (A TA)i j = ai T aj =  1 i f i = j 0 otherwise Therefore, because A TA = I, it follows that A −1 = A T . 2. For any matrix A, ATA and AAT are symmetric. (AAT ) T = A T TA T = AAT (A TA) T = A TA T T = A TA 3. A matrix is symmetric if and only if it is orthogonally diagonalizable. Because this statement is bi-directional, it requires a two-part “if-and-only-if” proof. One needs to prove the forward and the backwards “if-then” cases. Let us start with the forward case. If A is orthogonally di￾agonalizable, then A is a symmetric matrix. By hypothesis, orthogonally diagonalizable means that there exists some E such that A = EDET , where D is a diagonal matrix and E is some special matrix which diagonalizes A. Let us compute A T . A T = (EDET ) T = E T TD TE T = EDET = A Evidently, if A is orthogonally diagonalizable, it must also be symmetric. The reverse case is more involved and less clean so it will be left to the reader. In lieu of this, hopefully the “forward” case is suggestive if not somewhat convincing. 4. A symmetric matrix is diagonalized by a matrix of its orthonormal eigenvectors. Let A be a square n×n symmetric matrix with associated eigenvectors {e1,e2,...,en}. Let E = [e1 e2 ... en] where the i th column of E is the eigenvector ei . This theorem asserts that there exists a diagonal matrix D such that A = EDET . This proof is in two parts. In the first part, we see that the any matrix can be orthogonally diagonalized if and only if it that matrix’s eigenvectors are all linearly independent. In the second part of the proof, we see that a symmetric matrix

点击下载完整版文档(PDF)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共12页,试读已结束,阅读完整版请下载
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有