Abstract
This paper describes Sparse Frequent Directions, a variant of Frequent Directions for sketching sparse matrices. It resembles the original algorithm in many ways: both receive the rows of an input matrix $A \in \mathbb{R}^{n \times d}$ one by one in the streaming setting and compute a small sketch $B \in \mathbb{R}^{\ell \times d}$. Both share the same strong (provably optimal) asymptotic guarantees with respect to the space-accuracy tradeoff in the streaming setting. However, unlike Frequent Directions which runs in $O(nd\ell)$ time regardless of the sparsity of the input matrix $A$, Sparse Frequent Directions runs in $\tilde{O}(nnz(A)\ell + n\ell^2)$ time. Our analysis loosens the dependence on computing the Singular Value Decomposition (SVD) as a black box within the Frequent Directions algorithm. Our bounds require recent results on the properties of fast approximate SVD computations. Finally, we empirically demonstrate that these asymptotic improvements are practical and significant on real and synthetic data.
Introduction
In modern data analysis, information is frequently represented as massive, high-dimensional matrices. These matrices, such as document-term or user-product matrices, are typically sparse, with the vast majority of entries being zero. Matrix sketching is a critical technique for summarizing these datasets into a smaller matrix $B$ that preserves the essential properties of the original matrix $A$.
The Frequent Directions (FD) algorithm is widely regarded as the gold standard for matrix sketching due to its deterministic nature and optimal theoretical bounds for space-accuracy tradeoffs. However, FD's computational complexity is $O(nd\ell)$, where $n$ is the number of rows, $d$ is the dimension, and $\ell$ is the sketch size. This runtime does not account for sparsity, making it inefficient for real-world sparse data. This paper introduces Sparse Frequent Directions (SFD), which achieves a runtime proportional to the number of non-zero entries ($nnz$), providing significant speedups while maintaining the same accuracy guarantees.
Methodology
SFD innovates on the original FD algorithm by transitioning from exact linear algebra to randomized approximations. The algorithm incorporates three primary strategies:
- Buffer Strategy: SFD maintains a buffer and only triggers a "shrink" operation when the buffer reaches a threshold of non-zero entries or rows, reducing the frequency of expensive computations.
- Simultaneous Iteration: Instead of an exact SVD, SFD utilizes a randomized block power method to find the most significant directions. This approach focuses on non-zero elements, drastically reducing computation time.
- Boosting and Verification: To ensure reliability, the authors use a "BoostedSparseShrink" wrapper. This includes a spectral verifier that checks the accuracy of the randomized approximation and re-runs the process if necessary, ensuring the sketch meets strict theoretical requirements.
The figure above illustrates the randomized subspace iteration component. By computing $A(A^T A)^q G$, the algorithm identifies a subspace $Z$ that captures the dominant singular vectors of $A$ without the overhead of a full SVD.
Experimental Evaluation
The authors evaluated SFD against the standard FD algorithm using both synthetic and real-world datasets:
- Synthetic Data: Matrices were generated with controlled sparsity (non-zeros per row $z$) and low-rank signal structures.
- Real-World Data: A subset of the 20 Newsgroups dataset (117,759 rows, 3,000 columns, 0.15% sparsity) was used to test performance on natural data distributions.
Results and Discussion
The empirical results confirm that SFD offers substantial practical advantages:
- Computational Efficiency: SFD demonstrated speedups of 1.5x to 2x on standard sparse datasets, reaching over 10x on extremely sparse synthetic data.
- Scalability: Unlike FD, which scales with total dimensions $n \cdot d$, SFD scales linearly with the number of non-zero entries ($nnz$).
- Accuracy Preservation: SFD's accuracy, measured by Projection and Covariance Error, matches the original FD. Interestingly, SFD occasionally outperformed FD, likely because processing larger batches in the buffer leads to fewer total "shrink" operations.
Conclusion
Sparse Frequent Directions successfully bridges the gap between the theoretical optimality of Frequent Directions and the practical requirements of sparse, high-dimensional data processing. By replacing exact SVD with randomized approximations and a robust verification framework, SFD provides a scalable solution for streaming matrix sketching. Future work may explore further hyperparameter optimization and strategies to manage the density of the resulting sketch matrix.
Summary updated