![Ellafrederick](/avatars/30366.jpg)
Ellafrederick
07.06.2020 •
Computers and Technology
Thus, we can think of our data as 1000 observations of a 10000 variables (one variable per pixel). Run the followingcode to get a matrix of face observations.face_mat <-sapply(1:1000,function(i)as.numeric(faces_array[, , i]))%>%tWhen we want to visualization an image, we need to take the 10000 dimensional vector and reconstruct it as a matrix.The codeplot_facetakes a single 10000 dimensional vector (e.g. a column offace_mat), converts it back to amatrix, and plots the resulting image. You can test this functionality by printing a random face from the dataset:plot_face(face_mat[sample(1000, 1), ]).plot_face <-function(image_vector) {plot(as.cimg(t(matrix(image_vector,ncol=100))),axes=FALSE,asp=1)}a) Find the "average" face in this dataset by averaging all of the columns inface_mat. Plot the average face bycallingplot_faceon the average.b) Run PCA onface_matsettingcenter=TRUEandscale=FALSE. In class we mentioned that in general it is bestifscale=TRUEbecause it puts all variables on the same scale and we don’t have to worry about the units of thevariables (remember, the scale of the variables affects our results). In general, this is good practice, especiallywhen the predictor variables are of mixed types. Here, each variable represents a single pixel intensity (in black& white) and so all variables already have the same units and same scale (minimum of 0 and maximum of 255).In this case, settingscale=FALSEactually gives better results. Plot the PVE and cumulative PVE from thePCA. How many PCs do you need to explain at least 50% of the total variation in the face images?c) Plot the first 16 principle component directions as faces using theplot_facefunction (these are the columnsof therotationmatrix).Early researchers termed these "eigenfaces" since they are eigenvectors of thematrix of faces. The code below will adjust the margins of you plot and specifies a layout for the 16 images.par(mfrow=c(4,4))specifies a grid of 4 x 4 images. Each time you callplot_faceit will plot the next face inone of the new grid cells. All you need to do is callplot_face16 times (please use aforloop). Note that theseimages describe "directions" of maximum variability in the face images. You should interpret light and darkregions in the eigenfaces as regions of highcontrast, e.g. your interpretation should not change if you invertedblack and white in the images.par(mar=c(1,1,1,1))par(mfrow=c(4,4))d) In this part, we will examine faces that have the highest and lowest values for specific PCs. Plot the faceswith the 5 largest values on PC1 and the 5 smallest values for PC1. Based on the example faces, and the firsteigenface from the previous part and the 10 example images, what aspect of variability in the face images is captured by the first component?
Solved
Show answers
More tips
- C Computers and Internet Dropbox: What is it and How to Use it...
- H Health and Medicine How to Increase Hemoglobin in the Blood...
- A Animals and plants How to Store Carrots: Tips for Homeowners...
- L Legal consultation Juvenile Justice: Who Needs It?...
- F Family and Home How to Choose the Best Diapers for Your Baby?...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
- H Health and Medicine Kinesiology: What is it and How Does it Work?...
Answers on questions: Computers and Technology
- C Computers and Technology 1. foreground ___foreground processing is when the shell waits for a command to finish before issuing the prompt for another user command. 2. The first process that runs...
- C Computers and Technology How do I give someone the brainliest answer? First person to tell me gets brainliest...
- C Computers and Technology When working on this quiz, recall the rules stated on the Academic Integrity statement that you signed. You can download the q8helper project folder (available for Friday,...
- C Computers and Technology Ime: 30rning Q1. Write appropriate declaration for each group of variables. Integer variable: p, q...
- C Computers and Technology The player controls in a particular video game are represented by numbers. The controls and their corresponding binary values are shown in the following table, The numeric...
- B Business In the long run: select one: a. all costs are variable costs. b. all costs are fixed costs. c. variable costs equal fixed costs. d. fixed costs are greater than variable...
- S Social Studies Philosophers and psychologists have a shared interest in, among other things,...
- H History The role of the circuit courts is to review the trial record of cases decided in...
- S Social Studies Ajustice that agrees with the majority opinion but for different reasons is known as...
- H History Name the procession of finished costumes in front of the director and costume designer...
Ответ:
There are many menu items.