A bank vectorizes 2 million support tickets with TF-IDF over a 500,000-term vocabulary; the sparse matrix has about 100 non-zeros per row (≈ 2.4 GB in CSR format). For 300-dimensional latent semantic analysis (LSA), why is TruncatedSVD the standard choice rather than classic PCA?
Show the answer and explanation
Correct answer: A, Classic PCA centers each column, so every zero becomes minus its column mean and the 2M × 500k matrix turns dense; TruncatedSVD skips centering and works on the sparse matrix directly.
Explanation Dimensionality Reduction
PCA is the SVD of the column-centered data. Centering subtracts each term's mean TF-IDF weight from every row. Every term in a vocabulary learned from the tickets occurs at least once, so every column mean is positive and the ≈ 10¹² zero cells all become small negative numbers. Dense storage would need 2,000,000 × 500,000 × 8 bytes ≈ 8 TB, versus about 2.4 GB for the sparse matrix (≈ 2 × 10⁸ non-zeros × 12 bytes for values and column indices).
TruncatedSVD computes the top-k singular vectors of the uncentered matrix with randomized or ARPACK solvers that only need sparse matrix products, so memory grows with the non-zeros and the k-dimensional factors, not with the dense grid. On term-document matrices this is latent semantic analysis (LSA).
Consequences of skipping centering:
- The result differs from PCA: the first component largely follows the average TF-IDF profile rather than a contrast between topics.
- The output is often L2-normalized again (
Normalizer) before cosine-based clustering or retrieval.
Why the other explanations fail: L2-normalizing rows gives each document unit length but does not make column means zero. PCA never inverts the covariance matrix; it eigendecomposes it or runs an SVD of the data. TruncatedSVD does not standardize columns; IDF weighting is what down-weights common terms.
Recent scikit-learn versions (1.4+) also accept sparse input in PCA with the arpack solver, centering implicitly without forming the dense matrix, but TruncatedSVD remains the standard LSA tool.
Interview tip: add that dense sentence embeddings usually capture meaning better than LSA, while TF-IDF + TruncatedSVD stays a cheap, explainable baseline for clustering and search.