eigenface dr. hiren d. joshi dept. of computer science rollwala computer center gujarat university

73
Eigenface Eigenface Dr. Hiren D. Joshi Dr. Hiren D. Joshi Dept. of Computer Science Dept. of Computer Science Rollwala Computer Center Rollwala Computer Center Gujarat University Gujarat University

Upload: angel-eaton

Post on 11-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

EigenfaceEigenface

Dr. Hiren D. JoshiDr. Hiren D. JoshiDept. of Computer ScienceDept. of Computer ScienceRollwala Computer CenterRollwala Computer Center

Gujarat UniversityGujarat University

Page 2: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

EigenfaceEigenface

EigenfacesEigenfaces are a set of eigenvectors used in the are a set of eigenvectors used in the computer vision problem of human face recognition.computer vision problem of human face recognition.

The approach of using eigenfaces for recognition was The approach of using eigenfaces for recognition was developed by Sirovich and Kirby (1987) and used by developed by Sirovich and Kirby (1987) and used by Matthew Turk and Alex Pentland in face Matthew Turk and Alex Pentland in face classification. classification.

It is considered the first successful example of facial It is considered the first successful example of facial recognition technology. recognition technology.

These eigenvectors are derived from the covariance These eigenvectors are derived from the covariance matrix of the probability distribution of the high-matrix of the probability distribution of the high-dimensional vector space of dimensional vector space of possible faces of human possible faces of human beingsbeings..

Page 3: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Eigenface generation Eigenface generation

To generate a To generate a set of eigenfacesset of eigenfaces, a large set of , a large set of digitized images of human faces, taken under digitized images of human faces, taken under the same lighting conditions, are normalized to the same lighting conditions, are normalized to line up the eyes and mouths. line up the eyes and mouths.

They are then all resampled at the same pixel They are then all resampled at the same pixel resolution. Eigenfaces can be extracted out of resolution. Eigenfaces can be extracted out of the image data by means of a mathematical the image data by means of a mathematical tool called principal component analysis tool called principal component analysis (PCA).(PCA).

Page 4: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Eigenface generationEigenface generation

The eigenfaces that are created will appear as light The eigenfaces that are created will appear as light and dark areas that are arranged in a specific pattern.and dark areas that are arranged in a specific pattern.

This pattern is how different features of a face are This pattern is how different features of a face are singled out to be evaluated and scored. singled out to be evaluated and scored.

There will be a pattern to evaluate symmetry, if there There will be a pattern to evaluate symmetry, if there is any style of facial hair, where the hairline is, or is any style of facial hair, where the hairline is, or evaluate the size of the nose or mouth. evaluate the size of the nose or mouth.

Other eigenfaces have patterns that are less simple to Other eigenfaces have patterns that are less simple to identify, and the image of the eigenface may look identify, and the image of the eigenface may look very little like a face.very little like a face.

Page 5: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Eigenface generationEigenface generation

The technique used in creating eigenfaces and using The technique used in creating eigenfaces and using them for recognition is also used outside of facial them for recognition is also used outside of facial recognition. recognition.

This technique is also used for handwriting analysis, This technique is also used for handwriting analysis, lip reading, voice recognition, sign language/hand lip reading, voice recognition, sign language/hand gestures and medical imaging. gestures and medical imaging.

Therefore, some do not use the term eigenface, but Therefore, some do not use the term eigenface, but prefer to use 'eigenimage'. prefer to use 'eigenimage'.

Research that applies similar eigen techniques to sign Research that applies similar eigen techniques to sign language images has also been made.language images has also been made.

Page 6: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Eigenface generationEigenface generation Informally, eigenfaces are a set of "standardized face Informally, eigenfaces are a set of "standardized face

ingredients", derived from statistical analysis of many pictures ingredients", derived from statistical analysis of many pictures of faces. of faces.

Any human face can be considered to be a combination of Any human face can be considered to be a combination of these standard faces. these standard faces.

For example, your face might be composed of the average face For example, your face might be composed of the average face plus 10% from eigenface 1, 55% from eigenface 2, and even -plus 10% from eigenface 1, 55% from eigenface 2, and even -3% from eigenface 3. 3% from eigenface 3.

Remarkably, it does not take many eigenfaces summed Remarkably, it does not take many eigenfaces summed together to give a fair likeness of most faces. together to give a fair likeness of most faces.

Also, because a person's face is no longer recorded by a digital Also, because a person's face is no longer recorded by a digital photograph, but instead as just a list of values (one value for photograph, but instead as just a list of values (one value for each eigenface in the database used), much less space is taken each eigenface in the database used), much less space is taken for each person's face.for each person's face.

Page 7: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Practical implementation Practical implementation 1.1. Prepare a training set. Prepare a training set.

The faces constituting the training set should be of The faces constituting the training set should be of prepared for processing, in the sense that they should all prepared for processing, in the sense that they should all have the same resolution and that the faces should be have the same resolution and that the faces should be roughly aligned. roughly aligned.

Each image is seen as one vector, simply by Each image is seen as one vector, simply by concatenating the rows of pixels in the original image. concatenating the rows of pixels in the original image.

A greyscale image with A greyscale image with rr rows and rows and cc columns is columns is therefore represented as a vector with therefore represented as a vector with rr x x cc elements. elements.

In the following discussion we assume all images of the In the following discussion we assume all images of the training set are stored in a single matrix training set are stored in a single matrix TT, where each , where each row of the matrix is an image row of the matrix is an image

Page 8: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Practical implementationPractical implementation

2.2. Subtract the mean. Subtract the mean. The average image The average image aa has to be calculated and has to be calculated and

subtracted from each original image in subtracted from each original image in TT. .

Page 9: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Practical implementationPractical implementation

3.3. Calculate the eigenvectors and eigenvalues of Calculate the eigenvectors and eigenvalues of the covariance matrix the covariance matrix SS. .

Each eigenvector has the same dimensionality Each eigenvector has the same dimensionality as the original images and can itself be seen as as the original images and can itself be seen as an image. an image.

The eigenvectors of this covariance matrix are The eigenvectors of this covariance matrix are therefore called eigenfaces. therefore called eigenfaces.

They are the directions in which the images in They are the directions in which the images in the training set differ from the mean image. the training set differ from the mean image.

Page 10: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Practical implementationPractical implementation

4.4. Choose the principal components. Choose the principal components. The The DD x x DD covariance matrix will result in covariance matrix will result in DD

eigenvectors, each representing a direction in eigenvectors, each representing a direction in the image space. the image space.

Keep the eigenvectors with largest associated Keep the eigenvectors with largest associated eigenvalue. eigenvalue.

Page 11: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Practical implementationPractical implementation

The eigenfaces can now be used to represent new The eigenfaces can now be used to represent new faces: we can project a new (mean-subtracted) faces: we can project a new (mean-subtracted) image on the eigenfaces and thereby record how image on the eigenfaces and thereby record how that new face differs from the mean face. that new face differs from the mean face.

The eigenvalues associated with each eigenface The eigenvalues associated with each eigenface represent how much the images in the training set represent how much the images in the training set vary from the mean image in that direction. vary from the mean image in that direction.

We lose information by projecting the image on a We lose information by projecting the image on a subset of the eigenvectors, but we minimise this subset of the eigenvectors, but we minimise this loss by keeping those eigenfaces with the largest loss by keeping those eigenfaces with the largest eigenvalues. eigenvalues.

Page 12: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Practical implementationPractical implementation

For instance, if we are working with a For instance, if we are working with a 100 x 100 image, then we will obtain 100 x 100 image, then we will obtain 10,000 eigenvectors. 10,000 eigenvectors.

In practical applications, most faces In practical applications, most faces can typically be identified using a can typically be identified using a projection on between 100 and 150 projection on between 100 and 150 eigenfaces, so that most of the 10,000 eigenfaces, so that most of the 10,000 eigenvectors can be discarded.eigenvectors can be discarded.

Page 13: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Computing the eigenvectors Computing the eigenvectors Performing PCA directly on the covariance matrix of Performing PCA directly on the covariance matrix of

the images is often computationally infeasible. the images is often computationally infeasible. If small, say 100 x 100, greyscale images are used, each If small, say 100 x 100, greyscale images are used, each

image is a point in a 10,000-dimensional space and the image is a point in a 10,000-dimensional space and the covariance matrix covariance matrix SS is a matrix of 10,000 x 10,000 = is a matrix of 10,000 x 10,000 = 101088 elements. elements.

However the rank of the covariance matrix is limited by However the rank of the covariance matrix is limited by the number of training examples: if there are the number of training examples: if there are NN training training examples, there will be at most examples, there will be at most N-1N-1 eigenvectors with eigenvectors with non-zero eigenvalues. non-zero eigenvalues.

If the number of training examples is smaller than the If the number of training examples is smaller than the dimensionality of the images, the principal components dimensionality of the images, the principal components can be computed more easily as follows.can be computed more easily as follows.

Page 14: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Computing the eigenvectorsComputing the eigenvectors

Let Let TT be the matrix of preprocessed training be the matrix of preprocessed training examples, where each row contains one mean-examples, where each row contains one mean-subtracted image. subtracted image.

The covariance matrix can then be computed The covariance matrix can then be computed as as SS = = TTTT TT and the eigenvector decomposition and the eigenvector decomposition of of SS is given by is given by

Page 15: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Computing the eigenvectorsComputing the eigenvectors

However However TTTTTT is a large matrix, and if instead is a large matrix, and if instead we take the eigenvalue decomposition of we take the eigenvalue decomposition of

then we notice that by pre-multiplying both sides of the equation with TT, we obtain

Page 16: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Computing the eigenvectorsComputing the eigenvectors

Meaning that, if Meaning that, if uuii is an eigenvector of is an eigenvector of TTTTTT, , then then vvii==TTTTuuii is an eigenvector of is an eigenvector of SS. .

If we have a training set of 300 images of If we have a training set of 300 images of 100 x 100 pixels, the matrix 100 x 100 pixels, the matrix TTTTTT is a 300 x is a 300 x 300 matrix, which is much more manageable 300 matrix, which is much more manageable than the 10000 x 10000 covariance matrix.than the 10000 x 10000 covariance matrix.

Notice however that the resulting vectors Notice however that the resulting vectors vvi i are are not normalised; if normalisation is required it not normalised; if normalisation is required it should be applied as an extra step. should be applied as an extra step.

Page 17: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Use in facial recognition Use in facial recognition Facial recognition was the source of motivation Facial recognition was the source of motivation

behind the creation of eigenfaces. behind the creation of eigenfaces. For this use, eigenfaces have advantages over other For this use, eigenfaces have advantages over other

techniques available, such as the system's speed and techniques available, such as the system's speed and efficiency. efficiency.

Using eigenfaces is very fast, and able to functionally Using eigenfaces is very fast, and able to functionally operate on lots of faces in very little time. operate on lots of faces in very little time.

Unfortunately, this type of facial recognition does Unfortunately, this type of facial recognition does have a drawback to consider: trouble recognizing have a drawback to consider: trouble recognizing faces when they are viewed with different levels of faces when they are viewed with different levels of light or angles. light or angles.

Page 18: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Use in facial recognitionUse in facial recognition

For the system to work well, the faces need to be seen For the system to work well, the faces need to be seen from a frontal view under similar lighting. from a frontal view under similar lighting.

Face recognition using eigenfaces has been shown to Face recognition using eigenfaces has been shown to be quite accurate. be quite accurate.

By experimenting with the system to test it under By experimenting with the system to test it under variations of certain conditions, the following correct variations of certain conditions, the following correct recognitions were found: an average of 96% with recognitions were found: an average of 96% with light variation, 85% with orientation variation, and light variation, 85% with orientation variation, and 64% with size variation.64% with size variation.

(Turk & Pentland 1991, p. 590)(Turk & Pentland 1991, p. 590)

Page 19: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Use in facial recognitionUse in facial recognition

To complement eigenfaces, another approach To complement eigenfaces, another approach has been developed called eigenfeatures. has been developed called eigenfeatures.

This combines facial metrics (measuring This combines facial metrics (measuring distance between facial features) with the distance between facial features) with the eigenface approach.eigenface approach.

Another method, which is competing with the Another method, which is competing with the eigenface technique uses 'fisherfaces'. eigenface technique uses 'fisherfaces'.

This method for facial recognition is less This method for facial recognition is less sensitive to variation in lighting and pose of the sensitive to variation in lighting and pose of the face than the method using eigenfaces.face than the method using eigenfaces.

Page 20: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Use in facial recognitionUse in facial recognition

A more modern alternative to eigenfaces and A more modern alternative to eigenfaces and fisherfaces is the active appearance model, fisherfaces is the active appearance model, which decouples the face's shape from its which decouples the face's shape from its texture: it does an eigenface decomposition of texture: it does an eigenface decomposition of the face after warping it to mean shape. the face after warping it to mean shape.

This allows it to perform better on different This allows it to perform better on different projections of the face, and when the face is projections of the face, and when the face is tilted.tilted.

Page 21: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

PCAPCA

Page 22: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Standard Deviation

To understand standard deviation, we need a data set.

Statisticians are usually concerned with taking a sample of a population.

To use election polls as an example, the population is all the people in the country, whereas a sample is a subset of the population that the statisticians measure.

Page 23: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

The great thing about statistics is that by only measuring (in this case by doing a phone survey or similar) a sample of the population, you can work out what is most likely to be the measurement if you used the entire population.

Page 24: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

ExampleExample

X = [1 2 4 6 12 15 25 45 68 67 65 98]X = [1 2 4 6 12 15 25 45 68 67 65 98] If I want to refer to an individual number in

this data set, I will use subscripts on the symbol X X to indicate a specific number.

Eg. X3 refers to the 3rd number in X namely the number 4.

Note that X X1 1 is the first number in the sequence.

Page 25: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

the symbol n will be used to refer to the number of elements in the set X. X.

There are a number of things that we can calculate about a data set.

For example,we can calculate the mean of the sample.

I assume that the reader understands what the mean of a sample is, and will only give the

formula:

Page 26: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Notice the symbol (X bar) to indicate the mean of the set X

All this formula says is “Add up all the numbers and then divide by how many there are”.

Page 27: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Unfortunately, the mean doesn’t tell us a lot about the data except for a sort of middle point.

For example, these two data sets have exactly the same mean (10), but are obviously quite different: [0 8 12 20] and [8 9 11 12][0 8 12 20] and [8 9 11 12]

So what is different about these two sets? It is the spread of the data that is different.

The Standard Deviation (SD) of a data set is a measure of how spread out the data is.

Page 28: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Standard DeviationStandard Deviation

“The average distance from the mean of the data set to a point”.

The way to calculate it is to compute the squares of the distance from each data point to the mean of the set, add them all up, divide by

n-1, and take the positive square root.

Page 29: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

SDSD

Where s is the usual symbol for standard deviation of a sample.

Page 30: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

SDSD

Page 31: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

the first set has a much larger standard deviation due to the fact that the data is much more spread out from the mean.

Page 32: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

VarianceVariance Variance is another measure of the spread of

data in a data set. In fact it is almost identical to the standard

deviation. The formula is this:

s2 is the usual symbol for variance of a sample. Both these measurements are measures of the spread of the data. Standard deviation is the most common measure, but variance is also used.

Page 33: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Covariance The last two measures we have looked at are purely 1-

dimensional. Data sets like this could be: heights of all the people in the room, marks for the last COMP101 exam etc.

However many data sets have more than one dimension, and the aim of the statistical analysis of these data sets is usually to see if there is any relationship between the dimensions.

For example, we might have as our data set both the height of all the students in a class, and the mark they received for that paper.

We could then perform statistical analysis to see if the height of a student has any effect on their mark.

Page 34: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Covariance

Standard deviation and variance only operate on 1 dimension, so that you could only calculate the standard deviation for each dimension of the data set independently of the other dimensions.

However, it is useful to have a similar measure to find out how much the dimensions vary from the mean with respect to each other.

Page 35: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Covariance

Covariance is such a measure. Covariance is always measured between 2

dimensions. If you calculate the covariance between one

dimension and itself, you get the variance.

Page 36: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Covariance

if you had a 3-dimensional data set (x,y,z ) then you could measure the covariance between the x and y dimensions, the x and z dimensions, and the y and z dimensions.

Measuring the covariance between x and x, or y and y, or z and z would give you the variance of the x ,y and z dimensions respectively.

Page 37: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Covariance

The formula for variance could also be written like this:

The formula for covariance:

Page 38: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Covariance

“For each data item, multiply the difference between the x value and the mean of x, by the difference between the y value and the mean of y. Add all these up, and divide by (n -1) ”.

Imagine we have gone into the world and collected some 2-dimensional data, say, we have asked a bunch of students how many hours in total that they spent studying COSC241, and the mark that they received.

Page 39: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Covariance

So we have two dimensions, the first is the H dimension, the hours studied, and the second is the M dimension, the mark received.

The exact value is not as important as it’s sign (ie. Positive or negative). If the value is positive, as it is here, then that indicates that both dimensions increase together, meaning that, in general, as the number of hours of study increased, so did the final mark.

Page 40: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Covariance

If the value is negative, then as one dimension increases, the other decreases. If we had ended up with a negative covariance here, then that would have said the opposite that as the number of hours of study increased the final mark decreased.

In the last case, if the covariance is zero, it indicates that the two dimensions are independent of each other.

Page 41: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University
Page 42: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Covariance

Page 43: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Since the covariance value can be calculated between any 2 dimensions in a data set, this technique is often used to find relationships between dimensions in high-dimensional data sets where visualization is difficult.

Cov(x,y) = Cov(y,x)

Page 44: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

The covariance Matrix

Covariance is always measured between 2 dimensions.

If we have a data set with more than 2 dimensions, there is more than one covariance measurement that can be calculated.

For example, from a 3 dimensional data set (dimensions x,y,z) you could calculate cov(x,y), (cov(x,z) and cov(y,z)).

Page 45: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

The covariance Matrix

In fact, for an n dimensional data set, you can calculate N!/((N-2)!*2) different covariance values.

A useful way to get all the possible covariance values between all the different dimensions is to calculate them all and put them in a matrix.

Page 46: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

The covariance Matrix

The definition for the covariance matrix for a

set of data with n dimensions is:

where Cn x n is a matrix with n rows and n columns, and Dimx is the xth dimension.

If you have an n dimensional data set, then the matrix has n rows and columns (so is square) and each entry in the matrix is the result of calculating the covariance between two separate dimensions.

Page 47: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

The covariance Matrix

Eg. The entry on row 2, column 3, is the covariance value calculated between the 2nd dimension and the 3rd dimension.

We’ll make up the covariance matrix for an imaginary 3 dimensional data set, using the usual dimensions x, y and z.

the covariance matrix has 3 rows and 3 columns, and the values are this:

Page 48: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

The covariance Matrix

Page 49: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

The covariance Matrix

Down the main diagonal, you see that the covariance value is between one of the dimensions and itself. These are the variances for that dimension.

The other point is that since cov(a,b) = cov(b,a), the matrix is symmetrical about the main diagonal.

Page 50: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Eigenvectors

We can multiply two matrices together, provided they are compatible sizes.

Eigenvectors are a special case of this. Consider the two multiplications between a

matrix and a vector In the first example, the resulting vector is not

an integer multiple of the original vector, whereas in the second example, the example is exactly 4 times the vector we began with.

Page 51: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Example of one non-eigenvector and one eigenvector

Example of how a scaled eigenvector is still an eigenvector

Page 52: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

The vector (from the second example multiplication) represents an arrow pointing from the origin, (0,0) to the point (3,2).

The other matrix, the square one, can be thought of as a transformation matrix.

If you multiply this matrix on the left of a vector, the answer is another vector that is transformed from it’s original position.

Page 53: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

It is the nature of the transformation that the eigenvectors arise from.

Imagine a transformation matrix that, when multiplied on the left, reflected vectors in the line y = x.

Then you can see that if there were a vector that lay on the line y=x it’s reflection it itself.

This vector (and all multiples of it, because it wouldn’t matter how long the vector was), would be an eigenvector of that transformation matrix.

Page 54: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Eigenvector PropertiesEigenvector Properties

Eigenvectors can only be found for square matrices. And, not every square matrix has eigenvectors.

An n x n matrix that does have eigenvectors, there are n of them.

Given a 3 X 3 matrix, there are 3 eigenvectors.

Page 55: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Eigenvector PropertiesEigenvector Properties

Even if we scale the vector by some amount before we multiply it, we still get the same multiple of it as a result.

This is because if you scale a vector by some amount, all you are doing is making it longer, not changing it’s direction.

Page 56: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Eigenvector PropertiesEigenvector Properties

All the eigenvectors of a matrix are perpendicular, ie. at right angles to each other, no matter how many dimensions you have.

Another word for perpendicular, in maths talk, is orthogonal.

This is important because it means that you can express the data in terms of these perpendicular eigenvectors, instead of expressing them in terms of the x and y axes.

Page 57: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

When mathematicians find eigenvectors, they like to find the eigenvectors whose length is exactly one.

This is because, as you know, the length of a vector doesn’t affect whether it’s an eigenvector or not, whereas the direction does.

So, in order to keep eigenvectors standard, whenever we find an eigenvector we usually scale it to make it have a length of 1, so that all eigenvectors have the same length.

Page 58: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

is an eigenvector, and the length of that vector is so we divide the original vector by this much to make it have a length of 1.

Page 59: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Eigenvalues

Eigenvalues are closely related to eigenvectors, in fact, we saw an eigenvalue

Notice how, in both those examples, the amount by which the original vector was scaled after multiplication by the square matrix was the same?

Page 60: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

Eigenvalues

No matter what multiple of the eigenvector we took before we multiplied it by the square matrix, we would always get 4 times the scaled vector as our result.

So you can see that eigenvectors and eigenvalues always come in pairs.

Page 61: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

PCAPCA

Principal Components Analysis (PCA) is a way of identifying patterns in data, and expressing the data in such a way as to highlight their similarities and differences.

Since patterns in data can be hard to find in data of high dimension, where the luxury of graphical representation is not available, PCA is a powerful tool for analysing data.

Page 62: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

PCAPCA

The other main advantage of PCA is that once you have found these patterns in the data, and you compress the data, ie. by reducing the number of dimensions, without much loss of information.

Page 63: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

PCA steps

1. Get some data

2. Subtract the mean

3. Calculate the covariance matrix

4. Calculate the eigenvectors and eigenvalues of the covariance matrix

5. Choosing components and forming a feature vector

6. Deriving the new data set

Page 64: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

1.1.

Page 65: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

2.2.

Page 66: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

3.3.

Page 67: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

4.4.

Page 68: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

5.5. once eigenvectors are found from the covariance

matrix, the next step is to order them by eigenvalue, highest to lowest.

This gives you the components in order of significance.

Now, if you like, you can decide to ignore the components of lesser significance.

You do lose some information, but if the eigenvalues are small, you don’t lose much.

If you leave out some components, the final data set will have less dimensions than the original.

Page 69: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

5.5.

If you originally have n dimensions in your data, and so you calculate n eigenvectors and eigenvalues, and then you choose only the first

p eigenvectors, then the final data set has only p dimensions.

Page 70: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

5.5.

What needs to be done now is you need to form a feature vector, which is just a fancy name for a matrix of vectors.

This is constructed by taking the eigenvectors that you want to keep from the list of eigenvectors, and forming a matrix with these eigenvectors in the columns.

Page 71: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

5.5.

Given our example set of data, and the fact that we have 2 eigenvectors, we have two choices.

We can either form a feature vector with both of the eigenvectors:

or, we can choose to leave out the smaller, less significant component and only have a single column:

Page 72: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

6.6.

Once we have chosen the components (eigenvectors) that we wish to keep in our data and formed a feature vector, we simply take the transpose of the vector and multiply it on the left of the original data set, transposed.

Page 73: Eigenface Dr. Hiren D. Joshi Dept. of Computer Science Rollwala Computer Center Gujarat University

6.6.

Where RowFeatureVector Where RowFeatureVector is the matrix with the eigenvectors in the columns transposed so that the eigenvectors are now in the rows, with the most significant eigenvector at the top.

RowDataAdjust is the mean-adjusted data transposed,

ie. the data items are in each column, with each row holding a separate dimension.