linear & non-linear discriminant analysis · discriminant analysis of child faces •does face...

13
Linear & Non-Linear Discriminant Analysis Hugh R. Wilson PCA Review Supervised learning Fisher linear discriminant analysis Nonlinear discriminant analysis Research example Multiple Classes Unsupervised learning

Upload: others

Post on 02-Jun-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Linear & Non-Linear Discriminant Analysis!

Hugh R. Wilson

• PCA Review!• Supervised learning!• Fisher linear discriminant analysis!• Nonlinear discriminant analysis!• Research example!• Multiple Classes!• Unsupervised learning

Page 2: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Reading

• Monday: Principal components: Kutz, pp. 387 (bottom) - 393!• Today: Linear discriminant analysis: Kutz, pp. 442 - 445

Page 3: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

PCA Summary

•PCA reveals data structure determined by covariance •Calculation for M measurements, N samples (N > M):

•Subtract means from measurements •Data covariance matrix CV •[Vector, EV] = eig(CV)

•Dimensionality reduction (e.g. retain 95% of variance)

•Can be implemented by brain learning networks

Page 4: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Nonlinear PCA•Nonlinear axes (a manifold) •Problem: not know shape of data in multi-dimensions •Similar problem in Discriminant Analysis

-1.5 -1 -0.5 0 0.5 1

-0.2

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

Page 5: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Supervised Category Learning

• Issue: learn to discriminate category to which each individual belongs based on measurements!

• M measurements on each individual!• Each individual labeled by category (e.g. dog vs. cat)!• Supervised: learning algorithm knows the correct

category in each case!• Simplest example: Fisher linear discriminant analysis!• Two categories (can be generalized)!• Use result to categorize new data (cross validation)

Page 6: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Fisher Linear Discriminant Analysis

• Maximize ratio of covariance between classes to covariance within classes by projection onto vector V!

• Covariance Between: CovBet!

• Covariance Within: CovWin!

• CovWin*V = λ CovBet*V (generalized eigenvalue problem)!• Solution: V = eig(inv(CovWin)*CovBet))!• V = vector for maximum class separation!• Project onto vector & find point for maximum discrimination!• Matlab demo

Page 7: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Fisher LDA Matlab Code• Calculate between and within covariances!• Eigenvalue problem!• Maximize ratio of CovBetween/CovBetween

CovBetween = cov([Dog; Cat]); CovDog = cov(Dog); CovCat = cov(Cat); CovWithin = (CovDog + CovCat)/2; (average category cov) [FLD, FV] = eig(inv(CovWithin)*CovBetween); (eigenvector)

Page 8: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Extension to Non-Linear Class Boundaries • Expand dimensionality of measurement space!• Include nonlinear functions of individual measurements!• x2, y2, xy, (x2 + y2), other nonlinear combinations!• Problem: don’t use too many or overfit data!• Matlab demo

-2 -1 0 1 2 3

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

Page 9: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Non-Linear Rationale

• Eigenvalue problem: linear algebra!• How can linear algebra deal with nonlinear boundaries?!• Increase dimensionality of data space with nonlinear

measurement combinations x2, xy, etc.!• Discriminant Analysis is still linear in finding the weighting of

each of those dimensions!• Solution: Ax + By + C x2 + Dxy + E y2!

• Linear in A, B, C, D, E

Page 10: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Discriminant Analysis of Child Faces

• Does face shape reveal whether child is male or female?!• Used 45 child faces!• PCA to reduce geometry from 28 to 9 dimensions (94% var)!• Non-linear discriminant analysis (included each PC2)!• Predicted gender of 23 new child faces (cross-validation)!• Results: 80% correct on training faces!• 78% correct on novel test faces

Page 11: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Extension to more Classes• Example: 3 classes A, B, C!• Do multiple 2-class discriminant analyses:!

• A versus (B + C)!• B versus (A + C)!• C versus (A + B)!

• Combine results!• Effective for both linear & non-linear discriminants!• Generalizes to many classes

Page 12: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Unsupervised Learning: Cluster Analysis

-5 -4 -3 -2 -1 0 1 2 3 4-6

-4

-2

0

2

4

6

• Given data without category labels!• Must learn number of categories & category membership!• Analysis: find clusters of nearest neighbours

Page 13: Linear & Non-Linear Discriminant Analysis · Discriminant Analysis of Child Faces •Does face shape reveal whether child is male or female?! •Used 45 child faces! •PCA to reduce

Summary•PCA reveals data structure determined by eigenvalues of covariance matrix

•Fisher LDA (Linear Discriminant Analysis) reveals best axis for data projection to separate two classes

•Eigenvalue problem for matrix (CovBet)/(CovWin) •Generalizes to multiple classes •Non-linear Discriminant Analysis: add nonlinear combinations of measurements (extra dimensions)

•Dimensionality reduction by PCA often used first to simplify Discriminant Analysis (child face example)

•Computer simulations of brain networks can compute PCA, LDA & NLDA