https://github.com/ammahmoudi/face-recognition
Face recognition using Eigen faces, PCA and support vector machines
https://github.com/ammahmoudi/face-recognition
eigenfaces face-recognition machine-learning ml pca svm
Last synced: 5 days ago
JSON representation
Face recognition using Eigen faces, PCA and support vector machines
- Host: GitHub
- URL: https://github.com/ammahmoudi/face-recognition
- Owner: ammahmoudi
- Created: 2023-10-29T21:23:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-29T21:34:30.000Z (over 2 years ago)
- Last Synced: 2025-12-05T01:43:46.759Z (6 months ago)
- Topics: eigenfaces, face-recognition, machine-learning, ml, pca, svm
- Language: Jupyter Notebook
- Homepage:
- Size: 2.2 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Face Classification by SVM on Eigenfaces
We are going to build a classifier (Face recognition using Eigen faces, PCA and support vector machines) to distinguish the faces of 40 people on a toy dataset. The dataset includes 400 pictures of 40 people faces, each by a 64*64 pixel picture.

## Code Explanation
### **Dataset and Visualization**:
- The dataset consists of **400 pictures** of **40 people's faces**, each represented by a **64x64 pixel image**.
- The code visualizes the first image of each class (person) using subplots.
### **Train-Test Split**:
- The data is split into train and test sets with a **70% train** and **30% test** split.
- Dimensions of the sets are printed.
### **Dimensionality Reduction (PCA)**:
- Principal Component Analysis (PCA) is used to reduce dimensionality.
- The number of components is chosen to keep **90% variance**.
- Scree plot shows the proportion of variance explained by each component.
### **Eigenfaces Visualization**:
- Eigenfaces are the top eigenvectors from PCA.
- The first 30 eigenfaces are plotted, showing facial features.

### **Transforming Data with PCA**:
- Train and test features are transformed using PCA.
### **SVM Classifier Training**:
- An SVM classifier is trained on the transformed data.
- Grid search is used for hyperparameter tuning.
### **Model Evaluation**:
- Model predictions are checked on test samples.
- Precision-Recall tradeoff is visualized.
- Decision threshold where recall equals precision is determined.
### **ROC/AUC Comparison**:
- A Random Forest classifier with 30 estimators is trained.
- ROC curve and AUC are calculated for both SVM and Random Forest.
- SVM has an AUC of 0.98, indicating good performance.
### **Classification Report and Confusion Matrix**:
- Classification report shows precision, recall, and F1-score for each class.
- Confusion matrix visualizes true/false classifications per class.