dimensionality reduction. outline from distances to points : – multidimensional scaling (mds) –...

38
Dimensionality reduction

Post on 19-Dec-2015

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Dimensionality reduction

Page 2: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Outline

• From distances to points : – MultiDimensional Scaling (MDS)– FastMap

• Dimensionality Reductions or data projections

• Random projections

• Principal Component Analysis (PCA)

Page 3: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Multi-Dimensional Scaling (MDS)

• So far we assumed that we know both data points X and distance matrix D between these points

• What if the original points X are not known but only distance matrix D is known?

• Can we reconstruct X or some approximation of X?

Page 4: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Problem

• Given distance matrix D between n points

• Find a k-dimensional representation of every xi point i

• So that d(xi,xj) is as close as possible to D(i,j)

Why do we want to do that?

Page 5: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

How can we do that? (Algorithm)

Page 6: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

High-level view of the MDS algorithm

• Randomly initialize the positions of n points in a k-dimensional space

• Compute pairwise distances D’ for this placement

• Compare D’ to D• Move points to better adjust their pairwise

distances (make D’ closer to D)• Repeat until D’ is close to D

Page 7: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

The MDS algorithm• Input: nxn distance matrix D• Random n points in the k-dimensional space (x1,…,xn)

• stop = false• while not stop– totalerror = 0.0– For every i,j compute

• D’(i,j)=d(xi,xj)

• error = (D(i,j)-D’(i,j))/D(i,j)• totalerror +=error

• For every dimension m: xim = (xim-xjm)/D’(i,j)*error

– If totalerror small enough, stop = true

Page 8: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Questions about MDS

• Running time of the MDS algorithm– O(n2I), where I is the number of iterations of the

algorithm

• MDS does not guarantee that metric property is maintained in d’

• Faster? Guarantee of metric property?

Page 9: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Problem (revisited)

• Given distance matrix D between n points

• Find a k-dimensional representation of every xi point i

• So that: – d(xi,xj) is as close as possible to D(i,j)

– d(xi,xj) is a metric – Algorithm works in time linear in n

Page 10: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

FastMap

• Select two pivot points xa and xb that are far apart.

• Compute a pseudo-projection of the remaining points along the “line” xaxb

• “Project” the points to a subspace orthogonal to “line” xaxb and recurse.

Page 11: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Selecting the Pivot Points

The pivot points should lie along the principal axes, and hence should be far apart.– Select any point x0

– Let x1 be the furthest from x0

– Let x2 be the furthest from x1

– Return (x1, x2)

x0

x2

x1

Page 12: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Pseudo-Projections

Given pivots (xa , xb ), for any third point y, we use the law of cosines to determine the relation of y along xaxb

The pseudo-projection for y

is

This is first coordinate.

xa

xb

y

cyda,y

db,y

da,b

2 2 2 2by ay ab y abd d d c d

2 2 2

2ay ab by

yab

d d dc

d

Page 13: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

“Project to orthogonal plane”

Given distances along xaxb

compute distances within the “orthogonal hyperplane”

Recurse using d ’(.,.), until k features chosen.

2 2'( ', ') ( , ) ( )z yd y z d y z c c

xb

xa

y

z

y’z’d’y’,z’

dy,z

cz-cy

Page 14: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

The FastMap algorithm

• D: distance function, Y: nxk data points• f=0 //global variable• FastMap(k,D)– If k<=0 return

– (xa,xb) chooseDistantObjects(D)

– If(D(xa,xb)==0), set Y[i,f]=0 for every i and return

– Y[i,f] = [D(a,i)2+D(a,b)2-D(b,i)2]/(2D(a,b))– D’(i,j) // new distance function on the projection– f++– FastMap(k-1,D’)

Page 15: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

FastMap algorithm

• Running time– Linear number of distance computations

Page 16: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

The Curse of Dimensionality

• Data in only one dimension is relatively packed

• Adding a dimension “stretches” the points across that dimension, making them further apart

• Adding more dimensions will make the points further apart—high dimensional data is extremely sparse

• Distance measure becomes meaningless

(graphs from Parsons et al. KDD Explorations 2004)

Page 17: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

The curse of dimensionality

• The efficiency of many algorithms depends on the number of dimensions d

– Distance/similarity computations are at least linear to the number of dimensions

– Index structures fail as the dimensionality of the data increases

Page 18: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Goals

• Reduce dimensionality of the data

• Maintain the meaningfulness of the data

Page 19: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Dimensionality reduction

• Dataset X consisting of n points in a d-dimensional space

• Data point xiєRd (d-dimensional real vector):

xi = [xi1, xi2,…, xid]• Dimensionality reduction methods:– Feature selection: choose a subset of the features– Feature extraction: create new features by

combining new ones

Page 20: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Dimensionality reduction

• Dimensionality reduction methods:– Feature selection: choose a subset of the features– Feature extraction: create new features by

combining new ones

• Both methods map vector xiєRd, to vector yi є Rk, (k<<d)

• F : RdRk

Page 21: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Linear dimensionality reduction

• Function F is a linear projection• yi = A xi

• Y = A X

• Goal: Y is as close to X as possible

Page 22: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Closeness: Pairwise distances

• Johnson-Lindenstrauss lemma: Given ε>0, and an integer n, let k be a positive integer such that k≥k0=O(ε-2 logn). For every set X of n points in Rd there exists F: RdRk such that for all xi, xj єX

(1-ε)||xi - xj||2≤ ||F(xi )- F(xj)||2≤ (1+ε)||xi - xj||2

What is the intuitive interpretation of this statement?

Page 23: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

JL Lemma: Intuition

• Vectors xiєRd, are projected onto a k-dimensional space (k<<d): yi = R xi

• If ||xi||=1 for all i, then,

||xi-xj||2 is approximated by (d/k)||xi-xj||2 • Intuition: – The expected squared norm of a projection of a

unit vector onto a random subspace through the origin is k/d

– The probability that it deviates from expectation is very small

Page 24: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

JL Lemma: More intuition

• x=(x1,…,xd), d independent Gaussian N(0,1) random variables; y = 1/|x|(x1,…,xd)

• z : projection of y into first k coordinates– L = |z|2, μ = E[L] = k/d

• Pr(L ≥ (1+ε)μ)≤1/n2 and Pr(L ≤ (1-ε)μ)≤1/n2

• f(y) = sqrt(d/k)z• What is the probability that for pair (y,y’): |f(y)-f(y’)|

2/(|y-y’|) does not lie in range [(1-ε),(1+ ε)]?• What is the probability that some pair suffers?

Page 25: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Finding random projections

• Vectors xiєRd, are projected onto a k-dimensional space (k<<d)

• Random projections can be represented by linear transformation matrix R

• yi = R xi

• What is the matrix R?

Page 26: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Finding random projections

• Vectors xiєRd, are projected onto a k-dimensional space (k<<d)

• Random projections can be represented by linear transformation matrix R

• yi = R xi

• What is the matrix R?

Page 27: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Finding matrix R

• Elements R(i,j) can be Gaussian distributed • Achlioptas* has shown that the Gaussian distribution

can be replaced by

• All zero mean, unit variance distributions for R(i,j) would give a mapping that satisfies the JL lemma

• Why is Achlioptas result useful?

6

1 prob with 1

3

2 prob with 0

6

1 prob with 1

),( jiR

Page 28: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Closeness: Capture data variance or..

• Principal Component Analysis (PCA)

• Project data X from Rd to Rk (k<<d) while maximizing the variance of the projected data

• Find dimensions that capture most of the “variability” in the data

Page 29: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

PCA: Intuition

• Intuition: find the axis that shows the greatest variation, and project all points into this axis

f1

e1e2

f2

Page 30: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Reminder of some basic linear algebra

• Eigenvalue and Singular Value Decomposition

• Definitions of eigenvalues/eigenvectors

• Singular values and singlular vectors

• Algorithms: Powermethod

Page 31: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Principal component analysis (PCA)

• Projection in 1-dimensional space (k=1)

• u1: space direction (u1Tu1 =1)

• Each xi is projected onto scalar u1T xi

• Mean of original points: x’=1/n∑i=1…n xi

• Mean of projected points: u1Tx’

• Variance of the projected points:

• with

111

2

1 '1

Suuxuxun

Tn

i

Tii

T

n

i

Tii xxxx

nS

1

''1

Page 32: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Principal Component Analysis (PCA)

• Problem: Find u1 to maximize projected variance:

• Subject to the constraint that

11 SuuT

111 uuT

Page 33: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Principal Component Analysis (PCA): 1-d case

• Problem: Find u1 to maximize projected variance:

• Subject to the constraint that

• Solution:– Variance is maximum when u1 is the eigenvector

of S that corresponds to the largest eigenvalue λ1

11 SuuT

111 uuT

Page 34: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

PCA: multidimensional cae

• Additional principal components:– Choose a new direction that maximizes the

projected variance amongst all possible directions orthogonal to those already considered

• Generalized problem: Find k-dimensional linear projection space, for which the variance of the projected data is maximized

Page 35: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

PCA: Multidimensional case

• Problem: Find u1,…,uk to maximize projected variance:

• Subject to the constraint that

• Solution:– u1,…,uk are the k eigenvectors of the covariance

matrix that correspond to the k largest eigenvalues λ1≥… ≥ λk of covariance matrix S

kTk uuSuu ,...,,..., 11

0 ,1 jijTj uuuu

Page 36: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Algorithms for PCA

• Evaluate mean x’• Evaluate covariance matrix S• Find k eigenvectors of S corresponding to the

k largest eigenvalues

• How can we do that?

• What is the computational cost?

Page 37: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

PCA: computational cost

• Eigenvector decomposition of an nxn matrix: O(n3)

• If we only need to find the first k principal components we can use power method: O(kd2)

Page 38: Dimensionality reduction. Outline From distances to points : – MultiDimensional Scaling (MDS) – FastMap Dimensionality Reductions or data projections

Singular Value Decomposition: SVD

• SVD is closely related to PCA

• The data matrix X is decomposed into X = UΣVT

– U: left singular vectors of X– V: right singular vectors of X– S: diagonal matrix with the singular values of X

• Projected data: UkTX

• SVD is also expensive to compu/te – faster methods/approximations exist