Compute the dd-dimensional mean vectors for the different classes from the dataset.
Compute the scatter matrices (in-between-class and within-class scatter matrix).
Compute the eigenvectors (e1,e2,...,ede1,e2,...,ed) and corresponding eigenvalues (λ1,λ2,...,λdλ1,λ2,...,λd) for the scatter matrices.
Sort the eigenvectors by decreasing eigenvalues and choose k eigenvectors with the largest eigenvalues to form a d×k dimensional matrix W (where every column represents an Eigenvector).
Use this d×kEigenvector matrix to transform the samples onto the new subspace. This can be summarized by the matrix multiplication: Y=X×WY=X×W (where X is a n×d-dimensional matrix representing the n samples, and y are the transformed n×k-dimensional samples in the new subspace).