7

An Introduction to Randomized Sketching (draft) – Wenjie Zheng – Statistical Lea...

 2 years ago
source link: http://www.zhengwenjie.net/sketch/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

An Introduction to Randomized Sketching (draft)

In this post, I will make an introductory presentation about sketching, a statistical technique to handle large datasets. First, I will give the intuitive idea behind sketching, which is also the most important and valuable part of this post. Then, I will describe the various sketching algorithms in detail. Finally, I will give a non-exhaustive list of theoretical results concerning the soundness of sketching. Since this post is an introduction, I will build my presentation around Ordinary Least Square, which is the first topic in every machine learning course and arguably the most popular technique.

Table of Contents

  • Intuitive Ideas
    • Ordinary Least Square
    • Projection
    • Subsampling
    • Partial Sketching
  • Sketching Matrices
    • Random Projection
    • Random Sampling
  • Theoretical Guarantees
    • Algorithmic View
    • Statistical View
    • Raskutti and Mahoney’s Results
    • Other Results

Intuitive Ideas

Ordinary Least Square

Let us consider the classic Ordinary Least Square problem. Given a dataset (X,Y)∈Rn×d×Rn, where n≫d, we want to calculate a ˆβ∈Rd, optimal in the following sense: ˆβ∈argminβ‖Y−Xβ‖2.

For simplicity, we assume rank(X)=d, which is true for most applications. Otherwise, we can reduce the dimension so that this assumption could be valid. When X is of full rank, ˆβ is unique and has the following closed-form formulation: ˆβ=X†Y=(XTX)−1XTY, where X†:=(XTX)−1X is the Moore-Penrose inverse.

The computation involves four steps:

  1. XTX, which is a matrix-matrix multiplication, yielding O(nd2) time complexity.
  2. The inverse of XTX, which yields O(d3) time complexity.
  3. XTY, which is a matrix-vector multiplication, yielding O(nd) time complexity.
  4. The multiplication of (XTX)−1 and XY, which is again a matrix-vector multiplication, yielding O(d2) time complexity.

Therefore, the dominant part, or the bottleneck, is the 1st step—XTX. For many modern applications, n may be on the order of 106–109 and d may be on the order of 103–104 [1]. Even though the time complexity is only linear in n, the gigantic n makes the computation challenging.

For this sake, statisticians have been thinking of reducing the sample size into a more manageable r, where d≲r≪n. They came up with two solutions, with one being the subsampling method and the other being the projection method. In the following, I will talk about the projection method first, since it is less straightforward.

Projection

Here, we consider each column of X and Y as a point in Rn, and we have d+1 points. Then, reducing sample size is equivalent to projecting these points into Rr. Of course, we need this projection to preserve the relationship between X and Y, so that we could recover the desired β later.

The existence of such projection is suggested by the Johnson–Lindenstrauss lemma [2]:

For a set A of m fixed points in Rn and ε>0, there exists a linear map S:Rn→Rr, where r=O(logmε2), such that for any point u∈A, we have (1−ε)‖u‖2≤‖S(u)‖2≤(1+ε)‖u‖2.

This lemma claims that there exists a linear projection preserving the Euclidean norm of a bunch of points. The existence of such a projection is a strong hint that we could learn a desired β in the lower-dimensional space.

Note: Michael W. Mahoney’s description of the Johnson–Lindenstrauss lemma is inaccurate. The probability clause therein is redundant.

The proof of this lemma adopts a probability approach. We construct a random linear projection and then prove that the probability of this random projection satisfying the above property is nonzero. Hence, we prove the existence. Since it is a non-constructing proof, we do not know what this desired projection is. We only know that if we try randomly (and not so hard), we can luckily finish with that desired projection.

Assuming now we have got this desired projection S, we want to solve the following problem: ˆβS:=argminβ‖SY−SXβ‖2, which has this closed-form expression: ˆβS=(SX)†SY Notice how we just replaced X and Y with SX and SY respectively. Therefore, the time complexity is O(rd2)≪O(nd2) once we have completed the projection. The tricky part is that the projection process is a matrix-matrix multiplication, which itself yields O(nrd)≿O(nd2) time complexity.

Warning: (SX)†=((SX)TSX)−1(SX)T only if rank(SX)=d.

Luckily, not all projections are born equal. Some projections, such as the Hadamard transform [3], are fast to compute.

Subsampling

Probably the most straightforward way of reducing sample size is subsampling. Statisticians use sample distribution to approximate the population distribution, which is their way to understand the world. Ordinary Least Square is used to learn the relationship between X and Y, which amounts to learning the joint distribution of (X,Y). Thus, subsampling is a natural candidate for sketching.

Talking about sampling, one can immediately think about uniform sampling, which amounts to sampling each data point with equal probability. This method can work, but we can do better, because not every data point is born equal. We can adopt importance sampling by giving each data point a weight proportional to its importance.

This technique is very similar to novel writing. In a novel, you don’t write about the life of an average Joe; instead, you write about typical characters. If it is a miser person, it must be the most miser person in the world.

Then, how to decide the importance of a data point? Statisticians use the leverage score. The leverage score of matrix X is defined as the diagonal entry of the hat matrix H=X(XTX)−1XT. One way to remember this formula is to be aware of the fact that ˆY=HY, where ˆY is the predicted output. The hat matrix is like putting a “hat” on Y. Also, this fact leads us to realize that the hat matrix is the (Jacobian) derivative of ˆY on Y: ∂ˆY∂Y=H. In particular, the i-th leverage score is the derivative of ˆYi on Yi: ∂ˆYi∂Yi. The larger the derivative is, the more sensitive ˆYi is to Yi, and the more important the i-th data point will be.

With Singular Value Decomposition, we can represent the leverage score with a more concise form. It is just the ℓ2-norm of each row of the left singular matrix. Given the singular value decomposition X=UΣVT, we have H=UUT, and thus Hii=‖Ui⋅‖22

It is easy to prove that the sum of all leverage scores, or equivalently, the trace of the hat matrix is equal to d. tr(H)=tr(UUT)=tr(UTU)=tr(Id)=d. Incidentally, the trace of the hat matrix is also the Frobenius norm of U.

Once we get the leverage scores, we can either use them directly as the sampling probability (i.e., πi=Hiid) or make a tradeoff between them and a prior (oftentimes the uniform distribution): πi=(1−θ)Hiid+θqi, where q is the prior and θ∈[0,1] is an arbitrary constant.

In terms of the time complexity, the bottleneck is (like the projection method) to compute the leverage scores. According to Raskutti and Mahoney, the naive way is to perform a QR decomposition to compute an orthogonal basis for X [4], which yields O(nd2) time complexity and provides no benefit compared to the original problem. Luckily, one can do the above QR decomposition in an approximate way and hence accelerate the computation [5].

Subsampling sometimes also involves a rescaling step, whose meaning will be evident in the next subsection.

Partial Sketching

The above two methods are all full sketching. In this subsection, I will first summarize them and then proceed to the so-called partial sketching.

Similar to the projection method, which is characterized by the projection matrix S, the subsampling method can also be characterized by a subsampling matrix. The only difference is that the projection matrix is a dense matrix, whereas the subsampling matrix is a sparse matrix with each row having a single nonzero entry.

Let us denote ˜X:=SX and ˜Y:=SY, the full sketching methods can be universally formulated as ˆβF:=argminβ‖˜Y−˜Xβ‖2. When ˜X is of full rank, we have furthermore ˆβF=(˜XT˜X)−1˜XT˜Y. Noticing that ˜XT˜Y only brings us marginal benefit compared to XTY (from O(n) to O(r)), we can apply the sketching only on the first part. This idea gives us the partial sketching: ˆβP=(˜XT˜X)−1XTY.

Then, ˜XT˜X can be regarded as an estimator of XTX. In particular, if S is a subsampling matrix with rescaling, ˜XT˜X is an unbiased estimator of XTX: E[˜XT˜X|XTX]=XTX It will be proved in the next section after we mathematically formulate the subsampling matrix and the rescaling matrix.

Sketching Matrices

Random Projection

There are so far 4 choices of projection matrices (the first two have high time complexity and thus are not practical for sketching):

  • Gaussian random variables
  • Rademacher random variables
  • Randomized Hadamard transform
  • Clarkson-Woodruff sketching

Gaussian random variables. In this case, the entries of the projection matrix S are i.i.d. Gaussian random variables. That is, Sij∼N(0,σ2).

Rademacher random variables. The Rademacher distribution is very similar to the Bernoulli distribution, with two exceptions though. The Bernoulli distribution has the support on 0,1, whereas the Rademacher distribution has the support on −1,+1. The Bernoulli distribution has the parameter θ characterizing the probability of 1, whereas the Rademacher distribution puts equal probability on +1 and −1. In this case, the projection matrix consists of entries of independent Rademacher random variables.

Randomized Hadamard transform.[3] Before adding the randomization in, let us first talk about the (deterministic and linear) Hadamard transform, aka Walsh–Hadamard transform. The Hadamard transform Hm is a 2m×2m matrix, dubbed the Hadamard matrix, which defines a linear transform in a 2m-dimensional space. The Hadamard matrix is symmetric and consists purely of ±1, and it has a special structure in that adjacent rows or columns confront each other equally with the same signs and opposite signs. For instance, in H1=(+1+1+1−1), the 2nd row confronts the 1st row first with +1 against +1 and then −1 against +1. The Hadamard matrices can be explicitly constructed with the recursive formula: Hm+1:=H1⊗Hm=(HmHmHm−Hm). A naive application of Hadamard transform involves multiplication by an n×n matrix, yielding O(n2) time complexity. Luckily, like the Fourier transform, it has a fast version: a divide-and-conquer strategy yields only O(nlogn) time complexity. That is all for the deterministic Hadamard transform. As for the randomized Hadamard transform, it is just the subsampling + Hadamard transform. Denote it as SHad, which is defined as SHad:=SunifHD, where D∈Rn×n is a diagonal matrix with random equiprobable ±1 entries, H∈Rn×n is the Hadamard matrix, and Sunif∈Rr×n is a uniform sampling matrix. Therefore, the randomized Hadamard transform is simply 1) randomly flipping the sample sign, 2) project on the basis defined by the Hadamard transform, and then 3) subsampling. The time complexity is O(dnlogn).

Note: Daniel Ahfock et al. got the time complexity of the randomized Hadamard transform wrong in their Table 1 [6].

Clarkson-Woodruff sketching.[7] The sketching matrix associated with Clarkson-Woodruff sketching is one having a single randomly chosen nonzero entry in each column, and that nonzero entry takes the value on ±1 with equal probability. In other words, Clarkson-Woodruff sketching is simply taking all n rows of (X,Y) and randomly smashing them together until it remains only r rows. The time complexity is O(nd), the lowest among all four.

Random Sampling

Let us suppose that we have already got the leverage scores and are prepared to do the subsampling. The sampling probability could be {πi}i=1,…,n, with πi=Hiid, or it could be a convex combination between the leverage score and a prior. Denote W∈Rr×n as the weighting matrix, with each row independently following a multinomial distribution parameterized by {πi}i=1,…,n. Then, we have Pr(Wij=1)=πj. The rescaling matrix R∈Rn×n is a diagonal matrix with Rii=1√rπi. The final sketching matrix is the product of the weighting matrix and the rescaling matrix S=WR.

Now let us prove that E[˜XT˜X|XTX]=XTX as we claimed earlier. E[˜XT˜X|XTX]=E[XTRTWTWRX|XTX]=XTRTE[WTW|XTX]RX=XTRTE[WTW]RX. Denote A:=E[WTW], then we have Aii=Er∑k=1W2ki=r∑j=1πi=rπi, and Aij=0 for i≠j, because Wki and Wkj cannot simultaneously be 1 (each row of W has a single 1). Thus A is a diagonal matrix, just like R, so we have RTAR=In×n. The proof is completed.

Theoretical Guarantees

There are two families of ways to evaluate the sketching effect. One is the algorithmic view, and the other is the statistical view. I will present both views and use Raskutti and Mahoney’s paper [1] as an example. After that, I will briefly mention some other results.

Algorithmic View

The algorithmic view sees the data (X,Y), and it wants to compute the optimal ˆβ so that ‖Y−Xˆβ‖2 is the smallest possible. In terms of sketching, it wants that ˆβS can achieve the same effect as ˆβ. Mathematically, ‖Y−XˆβS‖22‖Y−Xˆβ‖22 is expected to be close to 1.

The above quantity depends on both X and Y, which means that we are at the mercy of what nature offers us. Naturally, we want to quantify the worst-case performance. For this sake, we define the worst-case efficiency of a sketching matrix S: CWC(S):=supY‖Y−XˆβS‖22‖Y−Xˆβ‖22. We take supreme only on Y but not on X because we consider that the design X is for us to choose and that only the measure Y is uncontrollable. In the cases where both X and Y are uncontrollable, we may want to take supreme on both X and Y.

Statistical View

The statistical view does not see (X,Y) as what it is. Instead, it considers (X,Y) to be generated by some model Y=Xβ+ε, where ε is a noise vector with good properties. The unobservable β is important in that E[Y|X]=Xβ. In other words, it does not want Xˆβ to be close to Y; it wants that quantity to be close to Xβ. In terms of sketching, it wants ‖X(β−ˆβS)‖22‖X(β−ˆβ)‖22 to be close to 1.

The above quantity depends on X and Y (because of ˆβ and ˆβS), where X is oftentimes considered as the fixed design. This time, we do not take supreme on Y, since now we have a model governing the (conditional) distribution of Y. Instead, we take expectations. For this sake, we define the prediction efficiency of a sketching matrix S: CPE(S):=Eε‖X(β−ˆβS)‖22Eε‖X(β−ˆβ)‖22

Raskutti and Mahoney’s Results

In this subsection, I will selectively present some results in Raskutti and Mahoney’s paper [1]. I chose this paper because their results are unambiguously stated and easy to digest. In the following, I will summarize their results in a table, which includes theoretical guarantees associated with sampling with rescaling SR, sampling without rescaling SNR, sub-Gaussian projection SSGP, and randomized Hadamard projection SHad.

Note: A sub-Gaussian random variable is one with its tail equal to or thinner than the one of a Gaussian random variable. Obviously, Gaussian random variables and random variables with finite support are all sub-Gaussian. Therefore, the Gaussian sketching matrix and the Rademacher sketching matrix mentioned earlier are both sub-Gaussian projections.

There are two elements important to interpret the table. The first is that these theoretical guarantees hold only with probability. The reason is that no matter CWC(S) or CPE(S), they are all random variables because of S. Especially CPE(S), it takes expectation, but only on ε not on S. The other element is that these guarantees all come with a cost: they all require a minimum number of rows r for the sketching matrix.

S CWC CPE r SR 1+O(dr) O(nr) Ω(dlogd) SNR 1+O(dr) O(kr) Ω(dlogd) SSGP 1+O(dr) O(nr) Ω(logn) SHad 1+O(drlognd) O(nrlognd) Ω(dlogn(logd+loglogn))

The performance guarantee of SNR needs a special condition. That is, the distribution of the leverage scores is severely skewed. A large portion is concentrated on k data points. Hence, there is the k appearing in the numerator of CPE(SNR).

Note: I did not present the residual efficiency in their paper, for I think their proof (Lemma 1 therein) is flawed. I wrote a letter to Prof. Mahoney but did not receive any reply. In general, I cannot guarantee everything I cited are absolutely correct, but if I have a doubt, I will not convey it to my readers.

The above results give the upper bounds of the prediction efficiency. One can ask whether they are tight. Pilanci and Wainwright proved that they are indeed tight 8.

Other Results

The above results focus exclusively on the prediction power of ˆβS. One can also question the closeness of ˆβS to ˆβ. Denote the total sum of squares as TSS:=YTY, the residual sum of squares of the original OLS problem as RSS:=‖Y−Xˆβ‖22, and the model sum of squares of the original OLS problem as MSS:=‖Xˆβ‖22. We have [9] ‖ˆβF−ˆβ‖22=O(RSSσ2min(X)) for the full sketching estimator, where σmin(X) is the smallest singular value of X.

Also, we have [6] ‖ˆβP−ˆβ‖22=O(MSSσ2min(X)) for the partial sketching estimator.

References

  1. A Statistical Perspective on Randomized Sketching for Ordinary Least-Squares  ↩2 ↩3

  2. Extensions of Lipschitz mappings into a Hilbert space 

  3. Faster least squares approximation  ↩2

  4. Matrix Computations 

  5. Fast approximation of matrix coherence and statistical leverage 

  6. Statistical properties of sketching algorithms  ↩2

  7. Low rank approximation and regression in input sparsity time 

  8. Iterative Hessian Sketch: Fast and Accurate Solution Approximation for Constrained Least-Squares 

  9. Improved approximation algorithms for large matrices via random projections 


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK