This repository contains the code and documentation for a machine learning homework assignment. The assignment involves tasks related to image preprocessing, dimensionality reduction using PCA (Principal Component Analysis), classification using k-Nearest Neighbors (k-NN), and Non-negative Matrix Factorization (NMF).
This machine learning homework focuses on the following tasks:
-
Image Preprocessing and Visualization: Load a set of images, resize them to a common dimension, reshape them into 1D arrays, and apply PCA for dimensionality reduction. Visualize the images in a 2D space.
-
Explanation of PCA Results: Provide an explanation of the PCA results and the significance of image positions in the 2D space.
-
Classification Using k-Nearest Neighbors (k-NN): Perform image classification using the k-NN algorithm in both the original image space and the reduced PCA space. Evaluate the classification accuracy using 5-fold cross-validation.
-
Optimal Number of Principal Components for PCA: Experiment with different numbers of principal components in PCA and identify the optimal number that yields the best results.
-
Non-negative Matrix Factorization (NMF): Implement NMF with regularization on a synthetic dataset. Explore different parameter settings and track the number of iterations required for convergence.
Before running the code in this repository, make sure you have the following prerequisites:
- Python (version specified in the code)
- Required Python libraries (e.g., scikit-learn, NumPy, OpenCV, PIL)
- Jupyter Notebook or an integrated development environment (IDE) for running Python scripts
- Clone this repository to your local machine:
git clone https://github.com/NikosMav/Image-Analysis-with-PCA.git
-
Open the Jupyter Notebook or Python script provided in the repository.
-
Follow the instructions in the notebook/script to run the code for each task.
-
Examine the results and documentation provided in the notebook/script to understand the outcomes of each task.
- The results of the PCA visualization, k-NN classification, and NMF experiments can be found within the provided Jupyter Notebook or Python script.
This project is licensed under the MIT License - see the LICENSE.md file for details.