For this task we used the grayscale image of faces from the Labeled Faces in the Wild Project.
The left and right hand side of each face was a $64\times 32$ matrix and so the whole face was a $64\times 64$ matrix.
You might be highly skeptical about the efficacy of linear least squares in tackling such a problem, I certainly was, since it seems unlikely that the pixels in the right hand side of the face are linear combinations of the pixels in the left hand side of the face. But hey, it's always worth it to try, surprising things do happen!
But to apply linear least squares meant first choosing a way to represent each face as two row vectors, one for the left side of the face, and another for the right side of the face. In keeping with the "let's do this the simplest possible way first" approach I decided to simply collapse the left and right hand side matrix of each face along its columns into a row vector. The 12000 faces that we had in the training were too much to fit into memory, so I figured start small with 2000.
And voila!
![]() |
| Simple Linear Least Squares with 2000 Examples |
![]() |
| Simple Linear Least Squares with 4000 Examples |
So let's reflect for a moment and consider why this simple application of linear least squares is giving such poor results. There are two important things to notice about the system of linear equations that we set up. First our system is treating each pixel in the right hand side of the face as if it were a linear combination of all the pixels in the left hand side, an issue that we had pointed out earlier. Second, our system treats each pixel that we are trying to predict in isolation of all the other pixels that it is trying to predict. Stated another way, this system of linear equations weights all the wrong pixels in all the wrong ways, and none of the right pixels in any way. Uh oh... So how can we address this? What can we do to take advantage of the fact that human faces vary in highly structured ways while still only using linear least squares?
Enter the singular value decomposition! Recall that the singular value decomposition of a matrix $A\in \mathbb{R}^{m\times n}$ produces, among other things, a decomposition of $A$ into the sum of $r$ mutually orthogonal matrices, $Z_i$, where $r$ is the rank($A$). In other words, $A$ is a linear combination of these $r$ matrices. moreover, the structure of $A$'s variations are encapsulated in linear combinations of these matrices. So how can we apply that to our current problem? Well if we average the faces and apply the singular value decomposition to this average face we will obtain rank($A$) matrices which structure the ways in which the average of the faces in the data vary. If we think of each face as a linear combination of these matrices we can solve for this linear combination using the left hand side of the face and linear least squares. Then we can use this solution to predict the right hand side of the face!
And sooooo!
From the stand point of what we would like face prediction to be this is still bad. But considering that all we used was linear least squares, this is surprisingly good! It is also another case in point that often it is not the choice of model that matters so much as the form of the data to which the model is applied!













