This project demonstrates a classic pattern recognition pipeline for facial emotion classification using Principal Component Analysis (PCA) and Support Vector Machines (SVM). It was originally developed as part of a university coursework assignment and focuses on distinguishing between happy and neutral facial expressions.
By leveraging PCA for dimensionality reduction and SVM for classification, the model learns to extract the most informative features (Eigenfaces) and classify them with high accuracy.
The goal of this project is to classify facial images as either happy or neutral using a combination of Principal Component Analysis (PCA) and Support Vector Machines (SVM). The dataset consists of grayscale facial images labeled with their corresponding emotion. The processing pipeline follows a structured approach: first, the images are loaded and preprocessed to ensure consistency. Then, the central region of the face is cropped to eliminate distractions such as hair, clothes, and ears. Each 2D image is then flattened into a 1D vector to make it compatible with machine learning models. PCA is applied to reduce the dimensionality of the data and extract the most significant features (principal components). These features are then used to train an SVM classifier, which learns to distinguish between the two emotional states. Finally, the model’s performance is evaluated using standard metrics and a confusion matrix to assess classification accuracy and reliability.
Images are loaded from separate folders for each emotion. The script converts them to grayscale.
To focus on the facial region, the images are cropped to exclude irrelevant areas like hair, ears, and clothes.
Cropped 2D images are flattened into 1D vectors for processing.
- PCA is applied separately to each emotion class to reduce dimensionality and capture the main facial features (Eigenfaces).
- 15 principal components are retained, preserving ~90% of variance.
- Features from both emotions are concatenated.
- A support vector machine (
SVC) is trained on the PCA-transformed vectors. - Classification is evaluated using precision, recall, F1-score, and accuracy.
- Basics of face image preprocessing and feature engineering.
- How PCA works for image data.
- Training and evaluating a classification model using SVM.
- Performance metrics interpretation for classification tasks.
