Fast Randomized PCA for Sparse Data

Xu Feng, Yuyang Xie, Mingye Song, Wenjian Yu, Jie Tang

Abstract

Principal Component Analysis (PCA) is a fundamental tool in data science, yet its application to massive, sparse datasets is often limited by the computational overhead of traditional Singular Value Decomposition (SVD) solvers. This paper introduces frPCA, a randomized PCA algorithm specifically engineered for sparse data. By replacing standard QR factorizations with LU decomposition and implementing a flexible "odd-pass" power iteration scheme, frPCA achieves up to a 20x speedup over established methods like Matlab’s svds without compromising accuracy.

Introduction

In domains ranging from natural language processing to recommendation systems, PCA is used to extract latent structures from high-dimensional data. However, as datasets scale to millions of rows and columns, traditional iterative solvers like the Krylov-subspace-based svds encounter significant performance bottlenecks or memory exhaustion.

While randomized PCA (rPCA) offers a faster alternative for dense data, its standard implementations are inefficient for sparse matrices. The primary inefficiencies stem from the high cost of orthonormalization (QR factorization) and the rigid "even-pass" structure of power iterations. The authors identify that in the sparse world, the computational bottlenecks shift, requiring a rethink of the standard rPCA pipeline to minimize auxiliary overhead.

The frPCA Framework

The authors propose frPCA (Fast Randomized PCA) to address these sparse-specific bottlenecks through several key innovations:

1. LU Factorization for Numerical Stability

In the power iteration phase of rPCA, QR factorization is typically used to maintain numerical stability. The authors demonstrate that LU factorization—which is computationally cheaper—can provide sufficient stability for these iterations in practical scenarios. This shift significantly reduces the "auxiliary" overhead that often dominates sparse matrix computations.

2. The eigSVD Trick

To further accelerate the process, frPCA avoids performing a standard SVD on the small projected matrix $B$. Instead, it utilizes an "economic SVD" approach based on the eigendecomposition of $B^T B$.

Algorithm 2: The eigSVD procedure for efficient decomposition of the projected matrix.

As shown in Algorithm 2, this approach leverages the fact that $B$ is much smaller than the original data matrix, making the eigendecomposition highly efficient. For truncated SVD tasks, the algorithm is adapted into eigSVDs (Algorithm 3), which specifically targets the top $k$ components.

Algorithm 3: The eigSVDs variant for truncated SVD computation.

3. Flexible Power Iterations and Shape-Awareness

Standard rPCA typically requires an even number of passes over the data. frPCA introduces a modified scheme allowing for an odd number of passes, enabling a finer trade-off between runtime and accuracy. Additionally, the authors provide shape-aware variants (frPCA and frPCAt) optimized for "wide" or "tall" matrices, respectively.

Experimental Evaluation

The algorithm was rigorously tested on several real-world sparse datasets, including MovieLens (collaborative filtering), AMiner (information retrieval), and SNAP (social networks).

Performance and Scalability

frPCA demonstrated remarkable speed, performing up to 9.1x faster than basic randomized SVD and 20x faster than Matlab’s svds. Its memory efficiency was particularly evident on the massive AMiner dataset (12.8 million persons), where frPCA computed the top 100 principal components in under 400 seconds using only 23 GB of RAM on a 24-core machine. In contrast, all conventional methods failed due to Out-of-Memory (OOM) errors.

Accuracy

Despite the optimizations, accuracy remains high. The correlation coefficients between the principal components identified by frPCA and those from svds were nearly 1.0 (e.g., 0.9988 for the 29th component), indicating that the speed gains do not come at the cost of mathematical precision.

Discussion and Conclusion

The success of frPCA lies in identifying that perfect orthogonality is not required at every step of power iteration; numerical stability via LU factorization is sufficient. In the context of sparse data, where matrix-matrix multiplication is less dominant than in dense cases, optimizing these auxiliary steps is crucial.

While the current implementation is optimized for multi-core CPUs using MKL and OpenMP, the logic of frPCA could likely be extended to distributed computing environments to handle even larger "web-scale" matrices. Although the eigSVD approach could theoretically face issues with highly rank-deficient matrices, such cases are rare in real-world sparse data.

This research was conducted by Xu Feng, Yuyang Xie, Mingye Song, Wenjian Yu, and Jie Tang at the BNRist, Department of Computer Science and Technology, Tsinghua University, Beijing.

Summary updated

BibTeX
@inproceedings{feng2018fast,
  author = {Xu Feng and Yuyang Xie and Mingye Song and Wenjian Yu and Jie Tang},
  title = {{Fast Randomized PCA for Sparse Data}},
  booktitle = {ACML},
  year = {2018},
}
Figure