Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
CSCE 421 Assignment
This dataset contains images of the faces of 15 individuals. For each individual there are 11 images taken under a variety of conditions e.g., the person makes a happy expression, wears glasses etc.
Download the dataset from the above URL.
(a) [Code] Processing the data and calculating eigen values.
(1) Fill in the function qa1 load, which takes the folder name input, and returns the data (as a tuple). Please use matplotlib.image.imread to read images.
(2) Fill in the function qa2 preprocess that performs a min max scaling on the faces (the X in dataset). Please use preprocessing.MinMaxScaler.
(3) Fill in the function qa3 calc eig val vec, given the dataset and integer k returns the k eigen vectors (PCA components) and the corresponding to the top k eigenvalues. Hint: use PCA already imported from sklearn.
(b) [Written + Code] Plot a curve displaying the first k eigenvalues λ1, …, λk i.e. the energy of the first K principal components. How many components do we need to capture 50% of the energy? Report the curve and the answer to the question in the report. Fill the function qb plot written used to generate the plot. DO NOT place your code in any other function.
(c) [Written + Code] PCA and Eigen Faces
(1) [Code] Fill in the function qc1 reshape images, that returns eigen faces, given the image dimensions, and PCA object. Note: Eigen faces are re-shaped eigen vectors in the shape of the original image.
(2) [Written + Code] Plot any 10 eigen faces for values of k = len(dataset) (as given in the starter code), and fill in the code qc2 plot. There is no specific format for plotting. Place the plots in the report.
(d) [Written + Code] Projection and Reconstruction