Cs · Computer Science

How to Interpret SVD in Text Mining and Topic Analysis

Published By the 9to5Science editorial team

At a glance

  1. 1. Build the matrix

    Place terms in rows and documents in columns, using counts, binary values, or usually TF–IDF weights.

  2. 2. Factor the matrix

    Compute A = UΣVᵀ; singular vectors describe orthogonal directions shared by terms and documents.

  3. 3. Choose topics

    Keep the first k singular components, where large singular values represent the strongest patterns.

  4. 4. Read the components

    Inspect term weights and document coordinates, remembering that signs and scales require careful interpretation.

Singular value decomposition (SVD) is commonly used in text mining through latent semantic analysis (LSA), also called latent semantic indexing in information-retrieval applications. It reduces a large term-document matrix to a smaller set of directions that capture major patterns of word usage.

The key qualification is that an SVD component is not automatically a topic in the probabilistic sense. It is an algebraically defined direction in the data. You interpret it as a topic by examining which terms and documents have large coordinates on that direction.

Start with a term-document matrix

Suppose there are mm terms and nn documents. Construct a matrix A∈Rm×nA \in \mathbb{R}^{m \times n} with

  • one row for each term,
  • one column for each document, and
  • AijA_{ij} equal to the weight of term ii in document jj.

The weights might be raw counts, binary indicators, logarithmically scaled counts, or TF–IDF values. TF–IDF is often preferable because it reduces the influence of words that occur in nearly every document.

For example, with rows representing terms and columns representing documents,

A=[320013210002].A = \begin{bmatrix} 3 & 2 & 0\\ 0 & 1 & 3\\ 2 & 1 & 0\\ 0 & 0 & 2 \end{bmatrix}.

The first and third terms tend to occur together, while the second and fourth terms are more associated with the third document. SVD finds directions that summarize such co-occurrence patterns, even when the exact words differ between documents.

What the SVD factors mean

The SVD of AA is

A=UΣVT.A = U\Sigma V^{\mathsf T}.

For a full SVD:

  • UU contains orthonormal directions in term space;
  • Σ\Sigma is diagonal and contains nonnegative singular values;
  • VV contains orthonormal directions in document space.

If the singular values are ordered as

σ1≥σ2≥⋯≥0,\sigma_1 \geq \sigma_2 \geq \cdots \geq 0,

the first component explains the strongest matrix pattern, the second explains the strongest remaining orthogonal pattern, and so on. This is a statement about matrix approximation, not necessarily about independent real-world causes.

Writing the decomposition as a sum makes the structure clearer:

A=∑r=1rank⁡(A)σrurvrT,A = \sum_{r=1}^{\operatorname{rank}(A)} \sigma_r u_r v_r^{\mathsf T},

where uru_r is the rrth column of UU and vrv_r is the rrth column of VV.

Each component is a rank-one pattern. The vector uru_r gives the term-side weights, vrv_r gives the document-side weights, and σr\sigma_r gives the overall strength of that pattern.

How a component becomes an interpreted topic

Choose a reduced dimension kk and retain the first kk components:

Ak=UkΣkVkT.A_k = U_k\Sigma_kV_k^{\mathsf T}.

This is the best rank-kk approximation to AA under the usual Frobenius-norm and spectral-norm criteria. In practical terms, it smooths the matrix by retaining broad regularities and discarding weaker detail or noise.

To interpret component rr:

  1. Inspect the entries of uru_r associated with the largest absolute term weights.
  2. Inspect the entries of the corresponding document vector.
  3. Give the component a human-readable label only after examining both sets of terms and documents.

The representation of document jj in the reduced space is the jjth column of

ΣkVkT.\Sigma_k V_k^{\mathsf T}.

The row representation of term ii is the iith row of UkΣkU_k\Sigma_k. Some software instead reports UkU_k and VkV_k separately, so check whether the singular values have already been multiplied into the coordinates before comparing magnitudes.

Large positive or negative coordinates indicate association with opposite ends of a latent direction. A topic-like component may therefore have positive terms on one side and negative terms on the other. This often means the component contrasts two vocabularies rather than representing one pure subject.

A small exact example

Consider the matrix

A=[240120000].A = \begin{bmatrix} 2 & 4 & 0\\ 1 & 2 & 0\\ 0 & 0 & 0 \end{bmatrix}.

The first two rows have the same pattern, and the third row never occurs. The matrix has rank one. Its SVD can be written as

A=5[2/51/50][1/52/50].A = 5 \begin{bmatrix} 2/\sqrt{5}\\ 1/\sqrt{5}\\ 0 \end{bmatrix} \begin{bmatrix} 1/\sqrt{5} & 2/\sqrt{5} & 0 \end{bmatrix}.

Thus the only nonzero singular value is 55. The term vector is proportional to (2,1,0)(2,1,0), so the first term is twice as prominent as the second in this pattern, while the third term contributes nothing. The document vector is proportional to (1,2,0)(1,2,0), so the second document has twice the strength of the first and the third document has none.

In a real corpus, the first component might have large weights for words such as “interest,” “loan,” and “bank,” while documents about finance also receive large coordinates. You could label it a finance-related direction, but that label is your interpretation, not an output guaranteed by SVD.

Choosing the number of topics

There is no universal rule that says to retain exactly kk components. Common approaches include:

  • plotting the singular values and looking for an elbow;
  • measuring reconstruction error as kk increases;
  • evaluating retrieval, clustering, or classification performance;
  • using a validation set for the downstream task.

The fraction of squared matrix energy retained by the first kk components is often reported as

∑r=1kσr2∑r=1rank⁡(A)σr2.\frac{\sum_{r=1}^{k}\sigma_r^2}{\sum_{r=1}^{\operatorname{rank}(A)}\sigma_r^2}.

This is useful, but it is not automatically the percentage of “topics explained.” It measures how much squared matrix variation is retained.

Common interpretation mistakes

Treating SVD topics as probabilities

SVD weights can be negative and do not generally sum to one. They are not word probabilities. Probabilistic topic models such as latent Dirichlet allocation impose different constraints and have a different interpretation.

Ignoring the weighting scheme

Changing from raw counts to TF–IDF can substantially change the components. Stop-word removal, stemming, vocabulary selection, document-length normalization, and rare-word filtering also affect the result.

Reading only the singular vectors

The singular value matters. If you compare component strengths, use the singular values, and determine whether your software scales UU or VV by Σ\Sigma in its reported coordinates.

Assuming signs have fixed meaning

If (ur,vr)(u_r,v_r) is a valid pair, then (−ur,−vr)(-u_r,-v_r) is equally valid. SVD can reverse the sign of a component between runs or implementations without changing the represented matrix. Interpret relative signs within one component, not the absolute choice of positive versus negative.

Assuming topics are independent

SVD components are orthogonal in the mathematical vector-space sense. Human subjects are not necessarily orthogonal: a document about medical finance can relate to both a health component and an economic component. Orthogonality does not mean the real-world topics are unrelated.

Centering without a reason

For ordinary LSA, the sparse term-document matrix is usually decomposed directly after suitable text weighting. Centering columns, as in some statistical PCA workflows, changes the question and can destroy useful sparsity. Apply centering only when it is justified by the intended analysis.

A practical interpretation is therefore: the rrth SVD component is a strong, orthogonal pattern of term usage and document usage; its topic label is a human summary of the highest-weight terms and documents.

References

  1. Introduction to Information Retrieval, Christopher D. Manning, Prabhakar Raghavan, and Hinrich Schütze
  2. Indexing by Latent Semantic Analysis, Scott Deerwester, Susan Dumais, George Furnas, Thomas Landauer, and Richard Harshman
  3. Numerical Recipes: The Art of Scientific Computing, William H. Press et al.

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.