Simple and deterministic matrix sketching

Edo LibertyKDD 2013

Abstract

This paper introduces "Frequent-directions," a deterministic streaming algorithm for matrix sketching inspired by the classic Misra-Gries "frequent items" approach. Frequent-directions produces a compact summary of a massive matrix with an error rate that decays at $1/\ell$ (where $\ell$ is the sketch size), significantly outperforming the $1/\sqrt{\ell}$ convergence typical of standard randomized methods. The algorithm is simple to implement, perfectly parallelizable, and demonstrates superior accuracy and stability in empirical evaluations.

1. Introduction

In the era of "Big Data," information is frequently represented as massive matrices—such as document-word or image-pixel matrices. Analyzing these structures via Principal Component Analysis (PCA) or Singular Value Decomposition (SVD) is computationally prohibitive when datasets exceed available memory. Matrix sketching addresses this by creating a smaller matrix $B$ that approximates the original matrix $A$, specifically ensuring that the covariance and principal directions are preserved ($B^T B \approx A^T A$).

While randomized solutions like random projections, hashing, or row sampling are popular, they suffer from variance and slow error convergence. This work proposes a deterministic, one-pass streaming algorithm that provides higher accuracy with less noise than its randomized counterparts.

2. The Frequent-Directions Algorithm

The Frequent-directions algorithm processes a large matrix $A$ row-by-row, maintaining a small sketch matrix $B$ with $\ell$ rows. The process involves two primary phases:

  1. Filling: New rows from the stream are inserted into $B$ until the sketch is full.
  2. Shrinking: Once full, the algorithm performs an SVD on $B$, rotates it to align with its principal directions, and "shrinks" the singular values. By identifying a median energy level and subtracting it from all directions, the algorithm effectively zeros out at least half of the rows in the sketch, clearing space for subsequent data.

Unlike randomized methods that distribute data across the sketch, Frequent-directions systematically discards directions with the least information, mirroring how frequent-items algorithms discard infrequent elements.

3. Experimental Evaluation

The algorithm was evaluated using synthetic "signal-plus-noise" datasets ($A = SDU + N/\zeta$), where $S, D, U$ represent a low-rank signal and $N$ represents additive Gaussian noise. Experiments utilized matrices with $n=10,000$ rows and $m=1,000$ columns, with varying signal dimensions ($d$). Accuracy was measured by the spectral norm of the difference between the original and sketched covariance matrices: $\|A^T A - B^T B\|$.

4. Results

4.1 Accuracy and Convergence

In all tests, Frequent-directions significantly outperformed sampling, hashing, and random projections. As shown in Figure 1, the error for Frequent-directions (yellow circles) is consistently lower than randomized methods. Notably, the theoretical worst-case bound for Frequent-directions (cyan squares) often proved more accurate than the actual performance of its competitors.

Figure 1: Error comparison for signal dimension d=10. Frequent Directions (yellow circles) demonstrates significantly lower error than randomized methods like Hashing and Sampling.

4.2 Computational Efficiency

While hashing remains the fastest method due to its simplicity, Frequent-directions is computationally efficient for practical applications, with an amortized update time of $O(m\ell)$ per row. Figure 2 illustrates that while Frequent-directions is more expensive than simple sampling, it scales linearly and remains more efficient than complex randomized projections at larger sketch sizes.

Figure 2: Running time comparison versus sketch size. Frequent Directions (yellow) scales linearly and remains computationally viable compared to Random Projections.

5. Conclusion

Frequent-directions offers a robust, deterministic alternative to randomized matrix sketching. Its $1/\ell$ error convergence and perfect parallelizability make it ideal for distributed systems like MapReduce or Spark. Future work may focus on optimizing the SVD bottleneck with lighter orthogonalization steps and extending the algorithm to handle sparse matrices or entry-wise streaming updates.

Summary updated

BibTeX
@inproceedings{liberty2013simple,
  author = {Edo Liberty},
  title = {{Simple and deterministic matrix sketching}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2013},
  doi = {10.1145/2487575.2487623},
}
Figure