Girish Mahajan (Editor)

Kernel Fisher discriminant analysis

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

In statistics, kernel Fisher discriminant analysis (KFD), also known as generalized discriminant analysis and kernel discriminant analysis, is a kernelized version of linear discriminant analysis (LDA). It is named after Ronald Fisher. Using the kernel trick, LDA is implicitly performed in a new feature space, which allows non-linear mappings to be learned.

Contents

Linear discriminant analysis

Intuitively, the idea of LDA is to find a projection where class separation is maximized. Given two sets of labeled data, C 1 and C 2 , define the class means m 1 and m 2 to be

m i = 1 l i n = 1 l i x n i ,

where l i is the number of examples of class C i . The goal of linear discriminant analysis is to give a large separation of the class means while also keeping the in-class variance small. This is formulated as maximizing, with respect to w , the following ratio:

J ( w ) = w T S B w w T S W w ,

where S B is the between-class covariance matrix and S W is the total within-class covariance matrix:

S B = ( m 2 m 1 ) ( m 2 m 1 ) T S W = i = 1 , 2 n = 1 l i ( x n i m i ) ( x n i m i ) T .

The maximum of the above ratio is attained at

w S W 1 ( m 2 m 1 ) .

as can be shown by the Lagrange multiplier method (sketch of proof):

Maximizing J ( w ) = w T S B w w T S W w is equivalent to maximizing

w T S B w

subject to

w T S W w = 1.

This, in turn, is equivalent to maximizing I ( w , λ ) = w T S B w λ ( w T S W w 1 ) , where λ is the Lagrange multiplier.

At the maximum, the derivatives of I ( w , λ ) with respect to w and λ must be zero. Taking d I d w = 0 yields

S B w λ S W w = 0 ,

which is trivially satisfied by w = c S W 1 ( m 2 m 1 ) and λ = ( m 2 m 1 ) T S W 1 ( m 2 m 1 ) .

Kernel trick with LDA

To extend LDA to non-linear mappings, the data, given as the points x i , can be mapped to a new feature space, F , via some function ϕ . In this new feature space, the function that needs to be maximized is

J ( w ) = w T S B ϕ w w T S W ϕ w ,

where

S B ϕ = ( m 2 ϕ m 1 ϕ ) ( m 2 ϕ m 1 ϕ ) T S W ϕ = i = 1 , 2 n = 1 l i ( ϕ ( x n i ) m i ϕ ) ( ϕ ( x n i ) m i ϕ ) T ,

and

m i ϕ = 1 l i j = 1 l i ϕ ( x j i ) .

Further, note that w F . Explicitly computing the mappings ϕ ( x i ) and then performing LDA can be computationally expensive, and in many cases intractable. For example, F may be infinitely dimensional. Thus, rather than explicitly mapping the data to F , the data can be implicitly embedded by rewriting the algorithm in terms of dot products and using the kernel trick in which the dot product in the new feature space is replaced by a kernel function, k ( x , y ) = ϕ ( x ) ϕ ( y ) .

LDA can be reformulated in terms of dot products by first noting that w will have an expansion of the form

w = i = 1 l α i ϕ ( x i ) .

Then note that

w T m i ϕ = 1 l i j = 1 l k = 1 l i α j k ( x j , x k i ) = α T M i ,

where

( M i ) j = 1 l i k = 1 l i k ( x j , x k i ) .

The numerator of J ( w ) can then be written as:

w T S B ϕ w = w T ( m 2 ϕ m 1 ϕ ) ( m 2 ϕ m 1 ϕ ) T w = α T M α , where M = ( M 2 M 1 ) ( M 2 M 1 ) T .

Similarly, the denominator can be written as

w T S W ϕ w = α T N α , where N = j = 1 , 2 K j ( I 1 l j ) K j T ,

with the n th , m th component of K j defined as k ( x n , x m j ) , I is the identity matrix, and 1 l j the matrix with all entries equal to 1 / l j . This identity can be derived by starting out with the expression for w T S W ϕ w and using the expansion of w and the definitions of S W ϕ and m i ϕ

w T S W ϕ w = ( i = 1 l α i ϕ T ( x i ) ) ( j = 1 , 2 n = 1 l j ( ϕ ( x n j ) m j ϕ ) ( ϕ ( x n j ) m j ϕ ) T ) ( k = 1 l α k ϕ ( x k ) ) = j = 1 , 2 i = 1 l n = 1 l j k = 1 l ( α i ϕ T ( x i ) ( ϕ ( x n j ) m j ϕ ) ( ϕ ( x n j ) m j ϕ ) T α k ϕ ( x k ) ) = j = 1 , 2 i = 1 l n = 1 l j k = 1 l ( α i k ( x i , x n j ) 1 l j p = 1 l j α i k ( x i , x p j ) ) ( α k k ( x k , x n j ) 1 l j q = 1 l j α k k ( x k , x q j ) ) = j = 1 , 2 ( i = 1 l n = 1 l j k = 1 l ( α i α k k ( x i , x n j ) k ( x k , x n j ) 2 α i α k l j p = 1 l j k ( x i , x n j ) k ( x k , x p j ) + α i α k l j 2 p = 1 l j q = 1 l j k ( x i , x p j ) k ( x k , x q j ) ) ) = j = 1 , 2 ( i = 1 l n = 1 l j k = 1 l ( α i α k k ( x i , x n j ) k ( x k , x n j ) α i α k l j p = 1 l j k ( x i , x n j ) k ( x k , x p j ) ) ) = j = 1 , 2 α T K j K j T α α T K j 1 l j K j T α = α T N α .

With these equations for the numerator and denominator of J ( w ) , the equation for J can be rewritten as

J ( α ) = α T M α α T N α .

Then, differentiating and setting equal to zero gives

( α T M α ) N α = ( α T N α ) M α .

Since only the direction of w , and hence the direction of α , matters, the above can be solved for α as

α = N 1 ( M 2 M 1 ) .

Note that in practice, N is usually singular and so a multiple of the identity is added to it

N ϵ = N + ϵ I .

Given the solution for α , the projection of a new data point is given by

y ( x ) = ( w ϕ ( x ) ) = i = 1 l α i k ( x i , x ) .

Multi-class KFD

The extension to cases where there are more than two classes is relatively straightforward. Let c be the number of classes. Then multi-class KFD involves projecting the data into a ( c 1 ) -dimensional space using ( c 1 ) discriminant functions

y i = w i T ϕ ( x ) i = 1 , , c 1.

This can be written in matrix notation

y = W T ϕ ( x ) ,

where the w i are the columns of W . Further, the between-class covariance matrix is now

S B ϕ = i = 1 c l i ( m i ϕ m ϕ ) ( m i ϕ m ϕ ) T ,

where m ϕ is the mean of all the data in the new feature space. The within-class covariance matrix is

S W ϕ = i = 1 c n = 1 l i ( ϕ ( x n i ) m i ϕ ) ( ϕ ( x n i ) m i ϕ ) T ,

The solution is now obtained by maximizing

J ( W ) = | W T S B ϕ W | | W T S W ϕ W | .

The kernel trick can again be used and the goal of multi-class KFD becomes

A = argmax A = | A T M A | | A T N A | ,

where A = [ α 1 , , α c 1 ] and

M = j = 1 c l j ( M j M ) ( M j M ) T N = j = 1 c K j ( I 1 l j ) K j T .

The M i are defined as in the above section and M is defined as

( M ) j = 1 l k = 1 l k ( x j , x k ) .

A can then be computed by finding the ( c 1 ) leading eigenvectors of N 1 M . Furthermore, the projection of a new input, x t , is given by

y ( x t ) = ( A ) T K t ,

where the i t h component of K t is given by k ( x i , x t ) .

Classification using KFD

In both two-class and multi-class KFD, the class label of a new input can be assigned as

f ( x ) = a r g min j D ( y ( x ) , y ¯ j ) ,

where y ¯ j is the projected mean for class j and D ( , ) is a distance function.

Applications

Kernel discriminant analysis has been used in a variety of applications. These include:

  • Face recognition and detection
  • Hand-written digit recognition
  • Palmprint recognition
  • Classification of malignant and benign cluster microcalcifications
  • Seed classification
  • References

    Kernel Fisher discriminant analysis Wikipedia