Top Banner
Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 1 LECTURE 9: Principal Components Analysis g The curse of dimensionality g Dimensionality reduction g Feature selection vs. feature extraction g Signal representation vs. signal classification g Principal Components Analysis
15

g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Jul 10, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

1

LECTURE 9: Principal Components Analysis

g The curse of dimensionalityg Dimensionality reductiong Feature selection vs. feature extractiong Signal representation vs. signal classificationg Principal Components Analysis

Page 2: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

2

g The curse of dimensionalityn A term coined by Bellman in 1961n Refers to the problems associated with multivariate data analysis as the

dimensionality increasesn We will illustrate these problems with a simple example

g Consider a 3-class pattern recognition problemn A simple approach would be to

g Divide the feature space into uniform binsg Compute the ratio of examples for each class at each bin and, g For a new example, find its bin and choose the predominant class in that bin

n In our toy problem we decide to start with one single feature and divide the real line into 3 segments

n After doing this, we notice that there exists too much overlap among the classes, so we decide to incorporate a second feature to try and improve separability

The curse of dimensionality (1)

x1x1

Page 3: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

3

g We decide to preserve the granularity of each axis, which raises the number of bins from 3 (in 1D) to 32=9 (in 2D)n At this point we need to make a decision: do we maintain the density of examples per bin or

do we keep the number of examples had for the one-dimensional case?g Choosing to maintain the density increases the number of examples from 9 (in 1D) to 27 (in 2D)g Choosing to maintain the number of examples results in a 2D scatter plot that is very sparse

g Moving to three features makes the problem worse:n The number of bins grows to 33=27n For the same density of examples the number of needed

examples becomes 81n For the same number of examples, well, the 3D scatter

plot is almost empty

The curse of dimensionality (2)

x1

x2

Constant density

x1

x2

x3

x1

x2

Constant # examples

Page 4: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

4

The curse of dimensionality (3)g Obviously, our approach to divide the sample space into equally

spaced bins was quite inefficientn There are other approaches that are much less susceptible to the curse of

dimensionality, but the problem still existsg How do we beat the curse of dimensionality?

n By incorporating prior knowledgen By providing increasing smoothness of the target functionn By reducing the dimensionality

g In practice, the curse of dimensionality means that, for a given sample size, there is a maximum number of features above which the performance of our classifier will degrade rather than improve

n In most cases, the additional information that is lost by discarding some features is (more than) compensated by a more accurate mapping in the lower-dimensional space

dimensionality

perfo

rman

ce

Page 5: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

5

The curse of dimensionality (4)g There are many implications of the curse of dimensionality

n Exponential growth in the number of examples required to maintain a given sampling density

g For a density of N examples/bin and D dimensions, the total number of examples is ND

n Exponential growth in the complexity of the target function (a density estimate) with increasing dimensionality

g “A function defined in high-dimensional space is likely to be much more complex than a function defined in a lower-dimensional space, and those complications are harder to discern” –Friedman

n This means that, in order to learn it well, a more complex target function requires denser sample points!

n What to do if it ain’t Gaussian?g For one dimension a large number of density functions can be found in textbooks, but

for high-dimensions only the multivariate Gaussian density is available. Moreover, for larger values of D the Gaussian density can only be handled in a simplified form!

n Humans have an extraordinary capacity to discern patterns and clusters in 1, 2 and 3-dimensions, but these capabilities degrade drastically for 4 or higher dimensions

Page 6: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

6

Dimensionality reduction (1)g Two approaches are available to perform dimensionality reduction

n Feature extraction: creating a subset of new features by combinations of the existing features

n Feature selection: choosing a subset of all the features (the ones more informative)

g The problem of feature extraction can be stated asn Given a feature space xi∈RN find a mapping y=f(x):RN→RM with M<N such that the

transformed feature vector yi∈RM preserves (most of) the information or structure in RN.n An optimal mapping y=f(x) will be one that results in no increase in the minimum

probability of errorg This is, a Bayes decision rule applied to the initial space RN and to the reduced space RM yield the

same classification rate

=

N

2

1

M

2

1

extractionfeature

N

2

1

i

i

i

selectionfeature

N

2

1

x

xx

f

y

yy

x

xx

x

xx

x

xx

M

2

1

MMM

Page 7: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

7

Dimensionality reduction (2)g In general, the optimal mapping y=f(x) will be a non-linear function

n However, there is no systematic way to generate non-linear transformsg The selection of a particular subset of transforms is problem dependent

n For this reason, feature extraction is commonly limited to linear transforms: y=Wxg This is, y is a linear projection of xg NOTE: When the mapping is a non-linear function, the reduced space is called a manifold

g We will focus on linear feature extraction for now, and revisit non-linear techniques when we cover multi-layer perceptrons

=

N

2

1

MN2M1M

N22221

N11211

M

2

1

extractionfeaturelinear

N

2

1

x

xx

www

wwwwww

y

yy

x

xx

MMOMM

L

L

M

Page 8: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

8

Signal representation versus classificationg The selection of the feature extraction mapping y=f(x) is guided by an

objective function that we seek to maximize (or minimize)g Depending on the criteria used by the objective function, feature

extraction techniques are grouped into two categories:n Signal representation: The goal of the feature extraction mapping is to represent

the samples accurately in a lower-dimensional spacen Classification: The goal of the feature extraction mapping is to enhance the

class-discriminatory information in the lower-dimensional spaceg Within the realm of linear feature

extraction, two techniques are commonly usedn Principal Components Analysis (PCA)

g uses a signal representation criterionn Linear Discriminant Analysis (LDA)

g uses a signal classification criterion

Feature 1

Feat

ure

2

Classif

icatio

n

Signal representation

1

2

111 1 1

1111 1

11

11

11 11

11

22

2 22

22

22 222 22 2 2

2

2

Page 9: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

9

Principal Components Analysis, PCA (1)g The objective of PCA is to perform dimensionality reduction while preserving as

much of the randomness (variance) in the high-dimensional space as possiblen Let x be an N-dimensional random vector, represented as a linear combination of

orthonormal basis vectors [ϕ1| ϕ2| ... | ϕN] as

n Suppose we choose to represent x with only M (M<N) of the basis vectors. We can do this by replacing the components [yM+1, …, yN]T with some pre-selected constants bi

n The representation error is then

n We can measure this representation error by the mean-squared magnitude of ∆xn Our goal is to find the basis vectors ϕi and constants bi that minimize this mean-square error

=≠

== ∑= ji1

ji0φ|φwhereφyx ji

N

1iii

∑∑+==

+=N

1Miii

M

1iii φbφy)M(x̂

( )∑∑∑∑+=+===

−=

+−=−=

M

1Miiii

N

1Miii

M

1iii

N

1iii φbyφbφyφy(M)xx∆x(M) ˆ

[ ] ( )( ) ( )[ ]∑∑ ∑+=+= +=

−=

−−==

N

1Mi

2ii

N

1Mi

N

1Mjj

Tijjii

22 byEφφbybyE)M(x∆E)M(ε

Page 10: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

10

Principal Components Analysis, PCA (2)n As we have done earlier in the course, the optimal values of bi can be found by computing

the partial derivative of the objective function and equating it to zero

g Therefore, we will replace the discarded dimensions yi’s by their expected value (an intuitive solution)n The mean-square error can then be written as

g where Σx is the covariance matrix of xn We seek to find the solution that minimizes this expression subject to the orthonormality

constraint, which we incorporate into the expression using a set of Lagrange multipliers λi

n Computing the partial derivative with respect to the basis vectors

g So ϕi and λi are the eigenvectors and eigenvalues of the covariance matrix Σx

( )[ ] [ ]( ) [ ]iiii2

iii

yEb0byE2byEb

=⇒=−−=−∂∂

( )[ ] ( ) ( )[ ]

( )( )[ ] ∑∑

∑∑

+=+=

+=+=

=−−=

−−=−=

N

1Miix

Ti

N

1Mii

TTi

N

1Miii

Tii

N

1Mi

2ii

2

φΣφφ]x[Ex]x[ExEφ

]φx[Eφx]φx[EφxE]y[EyE)M(ε

∑∑+=+=

−+=N

1Mii

Tii

N

1Miix

Ti

2 )φφ1(λφΣφ)M(ε

( )

( ) ( ) 2AxxAAAxxdxd:NOTE

φλφΣ0φλφΣ2)φφ(1λφΣφφ

(M)εφ

symmmetricisAif

TT

iiixiiix

N

1Mii

Tii

N

1Miix

Ti

i

2

i

=+=

=⇒=−=

−+

∂∂

=∂∂ ∑∑

+=+=

Page 11: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

11

Principal Components Analysis, PCA (3)n We can then express the sum-square error as

n In order to minimize this measure, λi will have to be smallest eigenvaluesg Therefore, to represent x with minimum sum-square error, we will choose the eigenvectors ϕi

corresponding to the largest eigenvalues λi.

∑∑∑+=+=+=

===N

1Mii

N

1Miii

Ti

N

1Miix

Ti

2 λφλφφΣφ)M(ε

PCA dimensionality reduction

The optimal* approximation of a random vector x∈ℜN by a linear combination of M (M<N) independent vectors is obtained by projecting the random vector x onto the eigenvectors ϕi corresponding to the largest eigenvalues λi of the covariance matrix Σx

*optimality is defined as the minimum of the sum-square magnitude of the approximation error

PCA dimensionality reduction

The optimal* approximation of a random vector x∈ℜN by a linear combination of M (M<N) independent vectors is obtained by projecting the random vector x onto the eigenvectors ϕi corresponding to the largest eigenvalues λi of the covariance matrix Σx

*optimality is defined as the minimum of the sum-square magnitude of the approximation error

Page 12: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

12

Principal Components Analysis, PCA (4)g NOTES

n Since PCA uses the eigenvectors of the covariance matrix Σx, it is able to find the independent axes of the data under the unimodal Gaussian assumption

g For non-Gaussian or multi-modal Gaussian data, PCA simply de-correlates the axesn The main limitation of PCA is that it does not consider class separability since it

does not take into account the class label of the feature vectorg PCA simply performs a coordinate rotation that aligns the transformed axes with the

directions of maximum varianceg There is no guarantee that the directions of maximum variance will contain good

features for discrimination

g Historical remarksn Principal Components Analysis is the oldest technique in multivariate analysisn PCA is also known as the Karhunen-Loève transform (communication theory)n PCA was first introduced by Pearson in 1901, and it experienced several

modifications until it was generalized by Loève in 1963

Page 13: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

13

PCA example (1) g In this example we have a three-dimensional

Gaussian distribution with the following parameters

g The three pairs of principal component projections are shown below

n Notice that the first projection has the largest variance, followed by the second projection

n Also notice that the PCA projections de-correlates the axis (we knew this since Lecture 3, though)

-10 -5 0 5 10

0510

-8

-6

-4

-2

0

2

4

6

8

10

12

x1x2

x3

-15 -10 -5 0 5 10 15

-5

0

5

10

15

y1

y3

-10 -8 -6 -4 -2 0 2 4 6 8 10

-2

0

2

4

6

8

10

12

y2

y3-15 -10 -5 0 5 10 15

-10

-5

0

5

10

y1

y2

[ ]

−−−

−==

10474417125

Σand250µ T

Page 14: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

14

PCA example (2)g This example shows a projection of a three-dimensional data set into two dimensions

n Initially, except for the elongation of the cloud, there is no apparent structure in the set of pointsn Choosing an appropriate rotation allows us to unveil the underlying structure. (You can think of this rotation

as "walking around" the three-dimensional set, looking for the best viewpoint)g PCA can help find such underlying structure. It selects a rotation such that most of the

variability within the data set is represented in the first few dimensions of the rotated datan In our three-dimensional case, this may seem of little usen However, when the data is highly multidimensional (10’s of dimensions), this analysis is quite powerful

Page 15: g The curse of dimensionality g Dimensionality reduction g ...sudeshna/courses/ml08/pca.pdf · Introduction to Pattern Analysis Ricardo Gutierrez-Osuna Texas A&M University 2 g The

Introduction to Pattern AnalysisRicardo Gutierrez-OsunaTexas A&M University

15

PCA example (3)g Compute the principal components for the

following two-dimensional datasetn X=(x1,x2)={(1,2),(3,3),(3,5),(5,4),(5,6),(6,5),(8,7),(9,8)}

g Let’s first plot the data to get an idea of which solution we should expect

g SOLUTION (by hand)n The (biased) covariance estimate of the data is:

n The eigenvalues are the zeros of the characteristic equation

n The eigenvectors are the solutions of the system

g HINT: To solve each system manually, first assume that one of the variables is equal to one (i.e. vi1=1), then find the other one and finally normalize the vector to make it unit-length

=

3.54.254.256.25

Σx

0.41;λ9.34;λ0λ-3.54.25

4.25λ-6.250λIΣλvvΣ 21xx ==⇒=⇒=−⇒=

=

=

=

=

0.810.59-

vv

vλvλ

vv

3.54.254.256.25

0.590.81

vv

vλvλ

vv

3.54.254.256.25

22

21

222

212

22

21

12

11

121

111

12

11

0 2 4 6 8 100

2

4

6

8

10

x1

x2

v1

v2