Faster Least Squares Approximation
Petros Drineas, Michael W. Mahoney, S. Muthukrishnan, Tamas Sarlos
Introduction
where denotes the Moore-Penrose generalized inverse of the matrix . This solution vector has a very natural statistical interpretation as providing an optimal estimator among all linear unbiased estimators, and it has a very natural geometric interpretation as providing an orthogonal projection of the vector onto the span of the columns of the matrix .
Recall that to minimize the quantity in eqn. (1), we can set the derivative of with respect to equal to zero, from which it follows that the minimizing vector is a solution of the so-called normal equations
Geometrically, this means that the residual vector is required to be orthogonal to the column space of , i.e., . While solving the normal equations squares the condition number of the input matrix (and thus is not recommended in practice), direct methods (such as the QR decomposition ) solve the problem of eqn. (1) in time assuming that . Finally, an alternative expression for the vector of eqn. (2) emerges by leveraging the Singular Value Decomposition (SVD) of . If denotes the SVD of , then
It is worth noting that our second algorithm has a (marginally) less restrictive assumption on the connection between and . However, the first algorithm is simpler to implement and easier to describe. Clearly, an interesting open problem is to relax the above constraints on for either of the proposed algorithms.
2 Related work
We should note several lines of related work.
First, techniques such as the “method of averages” preprocess the input into the form of eqn. (6) of Section 3 and can be used to obtain exact or approximate solutions to the least squares problem of eqn. (1) in time under strong statistical assumptions on and . To the best of our knowledge, however, the two algorithms we present and analyze are the first algorithms to provide nontrivial approximation guarantees for overconstrained least squares approximation problems in time, while making no assumptions at all on the input data.
Second, Ibarra, Moran, and Hui provide a reduction of the least squares approximation problem to the matrix multiplication problem. In particular, they show that time, where is the time needed to multiply two matrices, is sufficient to solve this problem. All of the running times we report in this paper assume the use of standard matrix multiplication algorithms, since matrix multiplication algorithms are almost never used in practice. Moreover, even with the current best value for the matrix multiplication exponent, , our algorithms are still faster.
Third, motivated by our preliminary results as reported in and , both Rokhlin and Tygert as well as Avron, Maymounkov, and Toledo have empirically evaluated numerical implementations of variants of one of the algorithms we introduce. We describe this in more detail below in Section 1.3.
Fourth, very recently, Clarkson and Woodruff proved space lower bounds on related problems ; and Nguyen, Do, and Tran achieved a small improvement in the sampling complexity for related problems .
3 Empirical performance of our randomized algorithms
In prior work we have empirically evaluated randomized algorithms that rely on the ideas that we introduce in this paper in several large-scale data analysis tasks. Nevertheless, it is a fair question to ask whether our “random perspective” on linear algebra will work well in numerical implementations of interest in scientific computation. We address this question here. Although we do not provide an empirical evaluation in this paper, in the wake of the original Technical Report version of this paper in 2007 , two groups of researchers have demonstrated that numerical implementations of variants of the algorithms we introduce in this paper can perform very well in practice.
In 2008, Rokhlin and Tygert describe a variant of our random projection algorithm, and they demonstrate that their algorithm runs in time
Their numerical experiments on this class of matrices clearly indicate that their implementations of variants of our algorithms perform well for certain matrices as small as thousands of rows by hundreds of columns.
In 2009, Avron, Maymounkov, Toledo introduced a randomized least-squares solver based directly on our algorithms. They call it Blendenpik, and by considering a much broader class of matrices, they demonstrate that their solver “beats LAPACK’s direct dense least-sqares solver by a large margin on essentially any dense tall matrix.” Beyond providing additional theoretical analysis, including backward error analysis bounds for our algorithm, they consider five (and numerically implement three) random projection strategies (i.e., Discrete Fourier Transform, Discrete Cosine Transform, Discrete Hartely Transform, Walsh-Hadamard Transform, and a Kac random walk), and they evaluate their algorithms on a wide range of matrices of various sizes and various “localization ” or “coherence” properties. Based on these results that empirically show the superior performance of randomized algorithms such as those we introduce and analyze in this paper on a wide class of matrices, they go so far as to “suggest that random-projection algorithms should be incorporated into future versions of LAPACK.”
4 Outline
After a brief review of relevant background in Section 2, Section 3 presents a structural result outlining conditions on preconditioner matrices that are sufficient for relative-error approximation. Then, we present our main sampling-based algorithm for approximating least squares approximation in Section 4 and in Section 5 we present a second projection-based algorithm for the same problem. Preliminary versions of parts of this paper have appeared as conference proceedings in the 17th ACM-SIAM Symposium on Discrete Algorithms and in the 47th IEEE Symposium on Foundations of Computer Science ; and the original Technical Report version of this journal paper has appeared on the arXiv . In particular, the core of our analysis in this paper was introduced in , where an expensive-to-compute probability distribution was used to construct a relative-error approximation sampling algorithm for the least squares approximation problem. Then, after the development of the Fast Johnson-Lindenstrauss transform , proved that similar ideas could be used to improve the running time of randomized algorithms for the least squares approximation problem. In this paper, we have combined these ideas, treated the two algorithms in a manner to highlight their similarities and differences, and considerably simplified the analysis.
Preliminaries
We will make frequent use of matrix and vector norms. More specifically, we let
denote the square of the Frobenius norm of , and we let
2 Linear Algebra background
3 Markov’s inequality and the union bound
We will make frequent use of the following fundamental result from probability theory, known as Markov’s inequality . Let be a random variable assuming non-negative values with expectation . Then, for all ,
We will also need the so-called union bound. Given a set of random events holding with respective probabilities , the probability that all events hold (i.e., the probability of the union of those events) is upper bounded by .
4 The Randomized Hadamard Transform
The Randomized Hadamard Transform was introduced in as one step in the development of a fast version of the Johnson-Lindenstrauss lemma . Recall that the (non-normalized) matrix of the Hadamard transform may be defined recursively as follows:
Our algorithms as preconditioners
Both of our algorithms may be viewed as preconditioning the input matrix and the target vector with a carefully-constructed data-independent random matrix . For our random sampling algorithm, we let , where is a matrix that represents the sampling operation and is the Randomized Hadamard Transform, while for our random projection algorithm, we let , where is a random projection matrix. Thus, we replace the least squares approximation problem of eqn. (1) with the least squares approximation problem
We explicitly compute the solution to the above problem using a traditional deterministic algorithm , e.g., by computing the vector
Alternatively, one could use standard iterative methods such as the the Conjugate Gradient Normal Residual method (CGNR, see for details), which can produce an -approximation to the optimal solution of eqn. (6) in time, where is the condition number of and is the number of rows of .
The two conditions that we will require of the matrix are:
for some . Several things should be noted about these conditions. First, although condition (9) depends on the right hand side vector , Algorithms 1 and 2 will satisfy it without using any information from . Second, although condition (8) only states that , for all , for both of our randomized algorithms we will show that , for all . Thus, one should think of as an approximate isometry. Third, condition (9) simply states that remains approximately orthogonal to . Finally, note that the following lemma is a deterministic statement, since it makes no explicit reference to either of our randomized algorithms. Failure probabilities will enter later when we show that our randomized algorithms satisfy conditions (8) and (9).
Proof: Let us first rewrite the down-scaled regression problem induced by as
Thus, by the normal equations (3), we have that
Taking the norm of both sides and observing that under condition (8) we have , for all , it follows that
To establish the first claim of the lemma, let us rewrite the norm of the residual vector as
where (19) follows since is the smallest singular value of and since the rank of is ; and (20) follows by (15) and the orthogonality of . Taking the square root, the second claim of the lemma follows.
If we make no assumption on , then (11) from Lemma 1 may provide a weak bound in terms of . If, on the other hand, we make the additional assumption that a constant fraction of the norm of lies in the subspace spanned by the columns of , then (11) can be strengthened. Such an assumption is reasonable, since most least-squares problems are practically interesting if at least some part of lies in the subspace spanned by the columns of .
Using the notation of Lemma 1 and assuming that , for some fixed it follows that
Proof: Since , it follows that
This last inequality follows from , which implies
By combining this with eqn. (11) of Lemma 1, the lemma follows.
A sampling-based randomized algorithm
In this section, we present our randomized sampling algorithm for the least squares approximation problem of eqn. (1). We also state and prove an associated quality-of-approximation theorem.
Remark: Assuming that , and using , we get that
Thus, the running time of Algorithm 1 becomes
Assuming that , the above running time reduces to
It is worth noting that improvements over the standard time could be derived with weaker assumptions on and . However, for the sake of clarity of presentation, we only focus on the above setting.
Remark: The assumptions in our theorem have a natural geometric interpretation.We would like to thank Ilse Ipsen for pointing out to us this geometric interpretation. In particular, they imply that our approximation becomes worse as the angle between the vector and the column space of increases. To see this, let , and note that . Hence the assumption can be simply stated as
2 The effect of the Randomized Hadamard Transform
In this subsection, we state a lemma that quantifies the manner in which approximately “uniformizes” information in the left singular subspace of the matrix . We state the lemma for a general orthogonal matrix such that , although we will be interested in the case when and consists of the top left singular vectors of the matrix .
Let be an orthogonal matrix and let the product be the Randomized Hadamard Transform of Section 2.4. Then, with probability at least ,
Proof: We follow the proof of Lemma 2.1 in . In that lemma, the authors essentially prove that the Randomized Hadamard Transform “spreads out” input vectors. More specifically, since the columns of the matrix (denoted by for all ) are unit vectors, they prove that for fixed and fixed ,
From a standard union bound, this immediately implies that with probability at least ,
holds for all and . Using
for all , we conclude the proof of the lemma.
3 Satisfying condition (8)
We now establish the following lemma which states that all the singular values of are close to one. The proof of Lemma 4 depends on a bound for approximating the product of a matrix times its transpose by sampling (and rescaling) a small number of columns of the matrix. This bound appears as Theorem 4 in the Appendix and is an improvement over prior work of ours in .
In the above, we used the fact that . We now can view as an approximation to the product of two matrices and by randomly sampling and rescaling columns of . Thus, we can leverage Theorem 4 from the Appendix. More specifically, consider the matrix . Obviously, since , , and are orthogonal matrices, and . Let ; since we assumed that eqn. (23) holds, we note that the columns of , which correspond to the rows of , satisfy
Thus, applying Theorem 4 with as above, , and implies that
holds with probability at least . For the above bound to hold, we need to assume the value of eqn. (26). Finally, we note that since , the assumption of Theorem 4 on the Frobenius norm of the input matrix is always satisfied. Combining the above with inequality (27) concludes the proof of the lemma.
4 Satisfying condition (9)
We next prove the following lemma, from which it will follow that condition (9) is satisfied by Algorithm 1. The proof of this lemma depends on bounds for randomized matrix multiplication algorithms that appeared in .
If eqn. (23) holds and , then with probability at least .9,
Proof: Recall that and that . We start by noting that since it follows that
Thus, we can view as approximating the product of two matrices and by randomly sampling columns from and rows/elements from . Note that the sampling probabilities are uniform and do not depend on the norms of the columns of or the rows of . However, we can still apply the results of Table 1 (second row) in page 150 of . More specifically, since we condition on eqn. (23) holding, the rows of (which of course correspond to columns of ) satisfy
for . Applying the result of Table 1 (second row) of we get
In the above we used . Markov’s inequality now implies that with probability at least .9,
Setting and using the value of specified above concludes the proof of the lemma.
5 Completing the proof of Theorem 2
We now complete the proof of Theorem 2. First, let denote the event that eqn. (23) holds; clearly, . Second, let denote the event that both Lemmas 4 and 5 hold conditioned on holding. Then,
In the above, denotes the complement of event . In the first inequality we used the union bound and in the second inequality we leveraged the bounds for the failure probabilities of Lemmas 4 and 5 given that eqn. (23) holds. We now let denote the event that both Lemmas 4 and 5 hold, without any a priori conditioning on event ; we will bound as follows:
In the first inequality we used the fact that all probabilities are positive. The above derivation immediately bounds the success probability of Theorem 2. Combining Lemmas 4 and 5 with the structural results of Lemma 1 and setting as in eqn. (22) concludes the proof of the accuracy guarantees of Theorem 2.
A projection-based randomized algorithm
In this section, we present a projection-based randomized algorithm for the least squares approximation problem of eqn. (1). We also state and prove an associated quality-of-approximation theorem.
In more detail, Algorithm 2 begins by preprocessing the matrix and right hand side vector with the Randomized Hadamard Transform of Section 2.4. This algorithm explicitly computes only those rows of and those elements of that need to be accessed to perform the sparse projection. After this initial preprocessing, Algorithm 2 will perform a “sparse projection” by multiplying and by the sparse matrix (described in more detail in Section 5.2). Then, we can consider the problem
Finally, the expected running time of the algorithm is (at most)
Remark: Assuming that we get that
Thus, the expected running time of Algorithm 2 becomes
Finally, assuming , the above running time reduces to
It is worth noting that improvements over the standard time could be derived with weaker assumptions on and .
2 Sparse projection matrices
In this subsection, we state a lemma about the action of a sparse random matrix operating on a vector. Recall that given any set of points in Euclidean space, the Johnson-Lindenstrauss lemma states that those points can be mapped via a linear function to dimensions such that the distances between all pairs of points are preserved to within a multiplicative factor of ; see and references therein for details.
Formally, let be an error parameter, be a failure probability, and be a “uniformity” parameter. In addition, let be a “sparsity” parameter defining the expected number of nonzero elements per row, and let be the number of rows in our matrix. Then, define the random matrix as in Algorithm 2. Matoušek proved the following lemma, as the key step in his version of the Ailon-Chazelle result .
3 Proof of Theorem 3
In this subsection, we provide a proof of Theorem 3. Recall that by the results of Section 3.1, in order to prove Theorem 3, we must show that the matrix constructed by Algorithm 2 satisfies conditions (8) and (9) with probability at least . The next two subsections focus on proving that these conditions hold; the last subsection discusses the running time of Algorithm 2.
In order to prove that all the singular values of are close to one, we start with the following lemma which provides a means to bound the spectral norm of a matrix. This lemma is an instantiation of lemmas that appeared in .
Let be a symmetric matrix and define the grid
In words, includes all -dimensional vectors whose coordinates are integer multiples of and satisfy . Then, the cardinality of is at most . In addition, if for every we have that , then for every unit vector we have that .
We next establish Lemma 8, which states that all the singular values of are close to one with constant probability. The proof of this lemma depends on the bound provided by Lemma 7 and it immediately shows that condition (8) is satisfied by Algorithm 2.
Assume that Lemma 3 holds. If and satisfy:
holds for all . Here and are the unspecified constants of Lemma 6.
holds for all . Consider the grid of eqn. (32) and note that there are no more than pairs , since by Lemma 7. Since , in order to show that , it suffices by Lemma 7 to show that , for all . To do so, first, consider a single pair. Let
By multiplying out the right hand side of the above equation and rearranging terms, it follows that
In order to use Lemma 6 to bound the quantities , and , we need a bound on the uniformity ratio . To do so, note that
The above inequalities follow by and Lemma 3. This holds for both our chosen points and and in fact for all . Let and let (these choices will be explained shortly). Then, it follows from Lemma 6 that by setting and our choices for and , each of the following three statements holds with probability at least :
Thus, combining the above with eqn. (36), for this single pair of vectors ,
holds with probability at least . Next, recall that there are no more than pairs of vectors , and we need eqn. (37) to hold for all of them. Since we set then it follows by a union bound that eqn. (37) holds for all pairs of vectors with probability at least .95. Additionally, let us set , which implies that thus concluding the proof of the lemma.
Finally, we discuss the values of the parameters and . Since , , and , the appropriate values for and emerge after elementary manipulations from Lemma 6.
3.2 Satisfying condition (9)
In order to prove that condition (9) is satisfied, we start with Lemma 9. In words, this lemma states that given vectors and we can use the random sparse projection matrix to approximate by , provided that (or , but not necessarily both) is bounded. The proof of this lemma is elementary but tedious and is deferred to Section 6.2 of the Appendix.
The following lemma proves that condition (9) is satisfied by Algorithm 2. The proof of this lemma depends on the bound provided by Lemma 9. Recall that and thus .
Assume that eqn. (23) holds. If and , then, with probability at least .9,
Proof: We first note that since , it follows that , for all . Thus, we have that
We now bound the expectation of the left hand side of eqn. (38) by using Lemma 9 to bound each term on the right hand side of eqn. (38). Using eqn. (24) of Lemma 3 we get that
holds for all . By our choice of the sparsity parameter the conditions of Lemma 9 are satisfied. It follows from Lemma 9 that
The last line follows since , for all . Using Markov’s inequality, we get that with probability at least ,
The proof of the lemma is concluded by using the assumed value of .
3.3 Proving Theorem 3
By our choices of and as in eqns. (31) and (30), it follows that both conditions (8) and (9) are satisfied. Combining with Lemma 1 we immediately get the accuracy guarantees of Theorem 3. The failure probability of Algorithm 2 can be bounded using an argument similar to the one used in Section 4.5.
References
Appendix
for all for some constant . Let be an accuracy parameter and assume . If
then, with probability at least ,
Proof: Consider the Exactly algorithm. Then
for . The matrix has columns , where are independent copies of . Using this notation, it follows that
We can now apply Lemma 1, p. 3 of . Notice that from eqn. (41) and our assumption on the spectral norm of , we immediately get that
with probability at least . Let be the failure probability of Theorem 4; we seek an appropriate value of in order to guarantee . Equivalently, we need to satisfy
Recall that , and combine eqns. (42) and (39) to get . Combining with the above equation, it suffices to choose a value of such that
We now use the fact that for any , if then . Let , let , and note that if , since , , and are at most one. Thus, it suffices to set
which concludes the proof of the theorem.
2 The proof of Lemma 9
Let be the -th row of as a row vector, for , in which case
Rather than computing directly, we will instead use that . We first claim that . By linearity of expectation,
We first analyze for some fixed (w.l.o.g. ). Let denote the -th element of the vector and recall that , for , and also that . Thus,
By combining the above with eqn. (44), it follows that , and thus that . In order to provide a bound for , note that
Eqn. (45) follows since the random variables are independent (since the elements of are independent) and eqn. (46) follows since is constant. In order to bound eqn. (46), we first analyze for some (w.l.o.g. ). Then,
We will bound the term directly:
Notice that if any of the four indices appears only once, then the expectation corresponding to those indices equals zero. This expectation is non-zero if the four indices are paired in couples or if all four are equal. That is, non-zero expectation happens if
In the above we used . Since we assumed that , the second term on the right hand side of eqn. (49) is bounded by and the lemma follows since we have assumed that .