Performing face recognition with complete implementation in python of LDA algorithm for the classification of the input labeled images
I used the ORL dataset which has 10 images per 40 people,Every image is a grayscale image of size 92x112.
For more information about the data set:
https://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html
- Read the images and convert into a vector of 10304 (92*112) values corresponding to the image size.
- Split the data to training and testing with a percantage of 50 % for each batch
- Apply the LDA algorithm steps with a final goal of computing the eigen-values and eigen-vectors
- Apply the KNN algorithm with different K valuesfor the calssification phase, prediction the values of the test data batch and calculating the accuracy
- Compute a mean matrix of size (40,10304) whre each row maps to the mean vector for a class
- Compute an overall mean for all classes producing a vector of size (10304,1)
- Compute the between class scater matrix producing a large matrix of size (10304,10304)
- Compute the center class scatter matrix
- Compute the within class scatter matrix
- Compute the W value
- Finally compute the eigen values and eigen vectors limited to the number of classes (40)
- Before applying the KNN algorithm I mapped the training and testing data batches to the new dimensions by the dot product of each image matrix and the eigen vectors matrix.
- Applying KNN with different K values ranging from (1 -> 25) to get the estimated best value for K.