Principal Component Analysis and Higher Correlations for Distributed Data
Ravindran Kannan, Santosh Vempala, David Woodruff
Introduction
In modern large-scale machine learning problems the input data is often distributed among many servers, while the communication as well as time and space resources per server are limited. We consider two well-studied problems: (1) Principal Component Analysis (PCA), and (2) Generalized Higher-order correlations. Both problems study correlations between vectors. For the first problem, the vectors correspond to the rows of a matrix and we are interested in second-order correlations, while in the second problem we are interested in higher-order correlations among the vectors.
PCA is a central tool in many learning algorithms. The goal of PCA is to find a low-dimensional subspace that captures as much of the variance of a dataset as possible. By projecting the rows of a matrix onto this lower-dimensional subspace, one preserves important properties of the input matrix, but can now run subsequent algorithms in the lower-dimensional space, resulting in significant computational and storage savings. In a distributed setting, by having each server first locally project his/her own data onto a low-dimensional subspace, this can also result in savings in communication. PCA is useful for a variety of downstream tasks, e.g., for clustering or shape-fitting problems () and latent semantic analysis.
The second problem we consider is the Generalized Higher Order Correlation Problem. For this problem we assume server has an -dimensional vector with non-negative entries. Note that for PCA, it is useful and more general to allow the entries to be positive, negative, or zero. On the other hand, the non-negativity assumption for Generalized Higher Order Correlations is justified both by the applications we give , as well as the fact that it is impossible to achieve low communication without this assumption, as described in more detail below.
A special case of this problem is the well-studied frequency moment problem. That is, if server holds the vector , with coordinates , then the -th frequency moment of is , where, is a positive integer. This problem has been extensively studied in the data stream literature, starting with the work of . Known lower bounds for this problem from that literature rule out low communication algorithms when in the distributed setting when the number of servers grows as a power of (), or when there are only two servers and the entries are allowed to be negative . Here we overcome these lower bounds for smaller and indeed will develop algorithms and lower bounds for estimating , for a general class of functions .
We then extend these results to the following more general problem: there is a collection of vectors that is partitioned into parts - - and server holds . For each and each , there is an -dimensional vector wholly residing on server . Let and be functions. For a natural number , define the -th generalized moment as
There are many applications of higher-order correlations, and we only mention several here. For a document collection, we seek statistics (second, third and higher moments) of the number of documents in which each trigram (triples of terms) occurs. For a bipartite graph and constants , we want to estimate the number of (complete bipartite graph) subgraphs. For a time series of many events, we want to estimate the number of tuples for which each of the events occurs at each of the times .
Conceptually, for each , we can think of a vector with components - one for each distinct tuple . Suppose and let Our first theorem describes a way of estimating up to a -factor, where, each server uses polynomial time and polynomial space, but we try to optimize total communication while keeping the number of rounds constant. For this algorithm, server explicitly constructs the vector first, so it uses space. Thereafter the space is linear in the total size of all the . Our second theorem shows how to reduce space to linear in . This algorithm does not construct explicitly, but instead performs a rejection sampling procedure.
Before stating our theorems, we need some notation. Let be the least positive real number such that
Note that for (as in the -th frequency moment), , since for any non-negative real numbers , we have and taking , we see that the factor cannot be improved.
The communication and computations are not assumed to be synchronous. We arbitrarily denote one of the servers as the Central Processor (CP). A round consists of the CP sending a message to each server and each server sending an arbitrary length message to the CP. A round is complete when the CP has received messages from all servers from which it is expecting a message in that round. All servers communicate only with the CP, which, up to a factor of two, is equivalent to the servers communicating directly with each other (provided they indicate in their message who the message is being sent to). For formal details of this model, we refer the reader to Section 3 of . Our algorithms take polynomial time, linear space and rounds of communication.
Our Results
Low-rank matrix approximation and approximate PCA.
Our first set of results is for low-rank approximation: given an matrix , a positive integer and , find an matrix of rank at most such that
Here, for a matrix , the Frobenius norm is the sum of squares of the entries of . A basis for the rowspace of provides an approximate -dimensional subspace to project the rows of onto, and so is a form of approximate PCA. We focus on the frequently occurring case when is rectangular, that is, .
Consider the arbitrary partition model where an matrix resides in server and the data matrix . For any , there is an algorithm that, on termination, leaves a matrix in server such that the matrix is of rank and with arbitrarily large constant probability achieves using linear space, polynomial time and with total communication complexity real numbers. Moreover, if the entries of each are bits each, then the total communication is words each consisting of bits.
In contrast to the guarantees in Theorem 1.1, in the streaming model even with multiple passes, a simple encoding argument formalized in Theorem 4.14 of shows the problem requires communication. We bypass this problem by allowing the different servers to locally output a matrix so that is a -approximation to the best rank- approximation. We are not aware of any previous algorithms with less than communication in the arbitrary partition model.
In the row-partition model, in which each row of is held by a unique server, there is an word upper bound due to . This is also achievable by the algorithms of . As the row-partition model is a special case of our model in which for each row of , there is a unique server with a non-zero vector on that row, our result implies their result up to the low order term, but in a stronger model. For example, consider the case in which a customer corresponds to a row of , and a column to his/her purchases of a specific item. These purchases could be distributed across multiple servers corresponding to different vendors. Or in the case of search data, each column could correspond to a search term of a user, and the searches may be distributed across multiple servers for storage and processing considerations. These examples are captured by the arbitrary partition model but not by the row partition model.
The technique for our upper bound is based on a two-stage adaptive sketching process, and has played an important role in several followup works, including CUR Matrix Factorizations of and subspace embeddings for the polynomial kernel by .
Frequency moments and higher-order correlations.
Our next set of results are for estimating higher moments and higher-order correlations of distributed data.
Let and be as in (1). There are polynomial time, linear space bounded servers, where server holds a non-negative -vector . We can estimate up to a factor by an algorithm using total words of communication (from all servers) in rounds. Moreover, any estimation up to a factor needs in the worst case bits of communication.
We remark that the lower bound applies to any function with parameter , not a specific family of such functions.
Let , be monotone functions with as in (1). is a natural number and let be the generalized moment. We can approximate to relative error by an algorithm with communication at most words in rounds. Further, we use polynomial time and linear space.
A key feature of this algorithm, and our following ones, is worth noting: they involve no dependence on or , so they can be used when are implicitly specified and itself is very large, possibly infinite (provided, we can communicate each index ). In the theorem below is the set of coordinates of each vector. It is analogous to . We use , which when is infinite and the probabilities are densities, should be replaced with an integral; our theorem is also valid for the case when we have integrals.
Let , be monotone functions with as in (1). Server is able to draw (in unit time) a sample according to a probability distribution on . Also, server can estimate . Then with words of communication, CP can estimate to within relative error .
As a special case we consider the well-studied case of frequency moments. The best previous upper bound for the -th frequency moment problem in the distributed setting is by who gave an algorithm that achieves communication, so the complexity still depends, albeit mildly, on . Theorem 1.3 implies an algorithm with words of communication. We further improve this:
There are servers, with server holding a non-negative vector .The vector need not be written down explicitly in server . it just has to have the ability to (i) find to relative error and draw a sample according to . Then, to estimate to within relative error , there is an algorithm that communicates words Each communicated word is either an index or a value . in rounds.
Low-rank Approximation
For a matrix , define as: Recall that the rank- approximation problem is the following: Given an matrix , and , find an matrix of rank at most such that .
We are mainly concerned with communication, so we omit the tradeoffs of different compositions and just use a composition for which , is an matrix of words each consisting of bits, and can be specified using bits (using a -wise independent hash function, as first shown in ), see Theorem 2.1 below. Since we will assume that is at least , the bits to specify will be negligible, though we remark that the number of bits to specify can be further reduced using results of .
We will prove the following property about the top right singular vectors of for a subspace embedding .
We will combine this property with the following known property.
We can now state the algorithm, which we call AdaptiveCompress.
In AdaptiveCompress, the matrix is of size .
(of Theorem 2.1.) Suppose is a subspace embedding for the column space of . Form an orthonormal basis of using the right singular vectors of . Let be the basis.
Also, suppose now is an orthonormal basis consisting of the singular vectors of . Then, we have
Thus, as desired.
For the second part of the theorem, regarding the choice of , fix attention on one particular . We apply Theorem 2.2 of with of that theorem both set to of the current theorem and in the notation of that theorem. This states that for , if is an matrix with -wise independent entries uniform in , then for any fixed vector , with probability . We combine this with Lemma 4 in Appendix A of , based on , to conclude that for all vectors , with probability (for a different constant in the function).
Proof of Theorem 1.1: By definition of the AdaptiveCompress protocol, we have where all norms in this proof are the Frobenius norm.
Notice that and are projections onto orthogonal subspaces, where is the identity matrix. It follows by the Pythagorean theorem applied to each row that
where the second equality uses that , where is the number of columns of .
Observe that the row spaces of and are both in the row space of , and therefore in the column space of . It follows that since has orthonormal columns, and therefore
where the second equality uses that . Let be the best rank- approximation to the matrix . By Theorem 2.1, with probability , and so
Notice that the row space of is spanned by the top right singular vectors of , which are in the row space of . Let us write , where is a rank- matrix.
We apply the Pythagorean theorem to each row in the expression in (5), noting that the vectors and are orthogonal, where and are the -th rows of and , respectively. Hence,
and the last equality uses the definition of . By Theorem 2.2, with constant probability arbitrarily close to , we have
It follows by combining (2), (3), (4), (5), (6), (7), that , which shows the correctness property of AdaptiveCompress.
We now bound the communication. In the first step, by Theorem 2.2, can be set to and the matrix can be described using a random seed that is -wise independent. The communication of steps 1-3 is thus words. By Theorem 2.1, the remaining steps take words of communication.
To obtain communication with -bit words if the entries of the matrices are specified by bits, Server 1 can instead send to each of the servers. The -th server then computes and sends this to Server 1. Let , where is an orthonormal basis for the row space of , and is an change of basis matrix. Server 1 computes and sends this to each of the servers. Then, since each of the servers knows , it can compute . It can then compute the SVD of this matrix, from which it obtains , the projection onto its top right singular vectors. Then, since Server knows and , it can compute , as desired. Notice that in this variant of the algorithm what is sent is and , which each can be specified with -bit words if the entries of the are specified by bits.
2 Lower bound for low-rank approximation
Our reduction is from the multiplayer SUM problem.
() Suppose each of players has a binary vector with bits and the first player wants to compute mod with constant probability. Then the total communication needed is bits.
(of Theorem 1.2.) We reduce from the player SUM problem, in which each player has a binary matrix and the first player wants to learn their sum. By Theorem 2.3, this problem needs communication, since even the mod version of the problem requires this amount of communication. Now consider the -player problem -RESTRICT-SUM in which the first player has , the second player has , the remaining players have a binary matrix and the first player wants to learn the sum of all inputs. This also requires communication. This follows since if this problem could be solved with communication, then SUM with players would have communication by a simulation in which the first player of the -SUM problem simulates the first three players of the -RESTRICT-SUM problem.
In our -player low-rank approximation problem, we give the first player , the second player , and the remaining players each has a random binary matrix . Note that there is a unique rank- approximation to the sum of the player inputs, namely, it is the matrix . It follows that any algorithm which outputs a projection matrix for which , for any , must be such that is a projection onto the row space of . This follows because .
Now, since the first player has , his output is , where the row space of equals the row space of . Suppose the total communication of our problem is .
We use this to build a protocol for -RESTRICT-SUM, which has the same inputs as in our -player low rank approximation problem. Notice that is a matrix with rows in .
Claim. The span of the rows of can intersect in at most distinct points.
Let denote the row space of . We will bound the size of for prime with , where is the finite field with elements , and is the vector space over . This will be an upper bound on the size of . Since is -dimensional, so is . Hence the intersection has at most linearly independent points. These linearly independent points can be used to generate the remaining points in . The number of distinct combinations of these points is at most , bounding the intersection size.
Next, players agree on random vectors where via a public coin. The entries of need only be -wise independent, and as such can be agreed upon by all the players using only bits of communication. Each player then computes the inner products , …, for each . Here denotes the ’th row of a the ’th player’s matrix .
Frequency Moments and Higher Order Correlations
In this section, we prove Theorems (1.3), (1.4) and (1.6).
We begin with some common notation. For :
Let . The task is to estimate . We analyze the following algorithm. Let . The parameters in the algorithm will be specified presently.
To analyze the algorithm, we think of it differently: suppose CP picks for the first of its trials and asks that to pick according to its . Let be the random variable for that . Clearly the estimate made by the algorithm can be viewed as the average of i.i.d. copies of . So it will suffice to show that (i) is unbiased : I.e., and (ii) Var (whence, the variance of the average of i.i.d. copies of would have variance at most giving us the relative error bound.)
The first part is easy: Let be the probability that we pick by this process. Clearly, p_{i}=\sum_{t=1}^{s}{\sf Prob}(\text{ CP pickedt}){\sf Prob}(t\text{ picks }i)=\sum_{t}\frac{C_{t}}{B}\frac{f(a_{ti})}{C_{t}}=\frac{B_{i}}{B}. So, proving (i). For (ii), we have since, by the definition of and by monotonicity of , we have .
To prove the claimed resource bounds, note that polynomial time and linear space bounds are obvious, since, all that each server has to do is to compute all , sum them up and sample at most times. The communication is dominated by each of servers sending to CP which is words per server giving us a total of .
Now for the lower bound, we use (rather unsurprisingly) the set-disjointness problem. It is known ( ) that the following problem needs bits of communication even for a randomized algorithm: we distinguish between two situations: (a) Each of servers holds a subset of and the subsets are pairwise disjoint and (b) There is exactly one element common to all sets. We reduce this problem to ours. Let be the subset held by server . By definition of , there exist such that Let Let be defined by: and otherwise. If the sets are disjoint, then In the case (b) when the sets all share one element in common, Since , it follows that if we can estimate to relative error , then we can distinguish the two cases. But it is known that this requires bits of communication which is proving the lower bound.
(of Theorem (1.4): The only change is in the sampling algorithm:
Order the lexicographically. Start with the first as the sample and compute by making a pass through the entire data: For each , after are read, compute and sum over all .
Process the next similarly. After processing a , say, , compute and keep a running total of for all seen so far. Reject the old sample and replace it by the current with probability
If the old sampled is not rejected, just keep it as the sample and go to next .
The proof of correctness and linear space bound follow straightforwardly by plugging in this sampling algorithm into Theorem (1.3).
We next turn to a more refined algorithm for estimating frequency moments with near-optimal communication, using the specific function . Here is the algorithm.
(of Theorem (1.6): Let and and . Note: . CP can arrange to pick with probabilities , where, as we already saw. First pick sample according to . Then, CP tells all servers all these and collects all and thence all . Total communication is at most .
Let . Let range over , a total of values and let Then, Since each , we have . So we need only accurate estimates of those with . For each , if we pick u.a.r. a subset of of cardinality , then estimates to within for every satisfying .
For each , pick such a random subset from . We have to recognize for each , whether it is in . First, for each , we estimate as follows: We pick servers u.a.r. and take as our estimate of . If is the r.v. based on just one random server (namely for a u.a.r ), then and
From this it follows by averaging over samples that
We do such experiments and take the median of all of these to drive down the failure probability for a single to less than , whence, it is small by union bound for the failure of any of the at most indices ’s. Thus all the are estimated to a factor of by this process whp. Since is a fixed constant, this also means relative error in the estimate of .
The subset that intersects is then . Now for these ’s in , we collect all and find exactly. This costs us communication. Thus the overall communication is bounded by
We now extend the above theorem and proof for a wide class of functions satisfying a weak Lipschitz condition (and generalizing the case of moments).
For a monotone function , define
Alternatively, is the Lipschitz constant of wrt the “distance” , i.e.,
For the function , we see that .
For any function with ,
Let be any nonnegative, superlinear real function with . Suppose there are servers, with server holding a non-negative vector Then, to estimate to relative error , there is an algorithm that communicates words in rounds.
The algorithm is the following, essentially the same as in the moments case, with parameters defined in terms of for a general function in place of .
Pick an i.i.d. sample of indices , where each is picked according to .
CP now gets an i.i.d. sample of ’s, each according to .
For each , CP does the following:
Pick a subset of of cardinality u.a.r.
(of Thm. 3.3.) We point out the changes in the analysis from the special case of moments. Now we have and . Also . The reader will have noticed that has been replaced by in the above algorithm. The first phase remains the same, and at the end we either have a good approximation for or we know that .
In the next phase we estimate . To do this, we first estimate , then apply to this estimate. We need to analyze the error of both parts. For the first part, let as before. Then and since the server used to define is chosen uniformly at random, we have
The last phase for estimating and putting together the estimates for all the is again the same as in the case of moments.
Acknowledgements. We are grateful to Dick Karp and Jelani Nelson for helpful discussions, as well as the Simons Institute at Berkeley. Santosh Vempala was supported in part by NSF award CCF-1217793 and David Woodruff by the XDATA program of the Defense Advanced Research Projects Agency (DARPA), administered through Air Force Research Laboratory contract FA8750-12-C0323.