Singular Value Decomposition

Parsing the document collection generates a term-document frequency matrix. Each entry of the matrix represents the number of times that a term appears in a document. For a collection of several thousand documents, the term-document frequency matrix can contain hundreds of thousands of words. It requires too much computing time and space to analyze this matrix effectively. Also, dealing with high dimensional data is inherently difficult for modeling. To improve the performance, singular value decomposition (SVD) can be implemented to reduce the dimensions of the term-document frequency matrix. SVD transforms the matrix into a lower dimensional, more compact, and informative form.
A high number of SVD dimensions usually summarize the data better. But the higher the number, the more computing resources are required. The Text Cluster node determines the number of SVD dimensions based on the values of the SVD Resolution and Max SVD Dimensions properties. The value of the SVD Resolution property can be set to Low (default), Medium, or High. High resolution yields more SVD dimensions. The default value of the Max SVD Dimensions property is 100, and the value must be between 2 and 500. Suppose that the maximum number of SVD dimensions that you specify for the Max SVD Dimensions property is maxdim and these maxdim SVD dimensions account for p% of the total variance. High resolution always generates the maximum number of SVD dimensions, maxdim. For medium resolution, the recommended number of SVD dimensions account for 5/6*(p% of the total variance). For low resolution, the recommended number of SVD dimensions account for 2/3*(p% of the total variance).
The computation of the SVD is itself a memory-intensive task. For extremely large problems, the SVD might automatically perform a random sample of the documents in an attempt to avoid running out of memory. When this occurs, a note indicating that sampling has occurred will be written to the SAS log.
The SVD approximates the original weighted frequency matrix. It is the best least squares fit to that matrix. In other words, for any given k, the transformation output will be the factorization of the matrix with k dimensions that best approximates the original matrix. A higher value of k gives a better approximation to the matrix A. However, choosing too large a value for k might result in too high a dimension for the modeling process. Generally, the value of k must be large enough to preserve the meaning of the document collection, but not so large that it captures the noise. Values between 10 and 200 are appropriate unless the document collection is small. In SAS Text Miner, you can specify the number of dimensions (k). That is, you can specify the first k singular values to be calculated. The algorithm for computing the singular values is designed to give only the leading singular values. The value for k can be at most 4 fewer than the minimum of the number of rows and number of columns of A. In some cases, the algorithm might not be able to calculate that many singular values, so you must reduce the number of dimensions. As you carry out text mining, this problem does not usually occur. For your specific text mining application, you might want to compare the results for several values of k. As a general rule, smaller values of k (2 to 50) are useful for clustering, and larger values (30 to 200) are useful for prediction or classification.
SVD factors the large, sparse term-by-document frequency matrix by calculating a truncated SVD of the matrix. Then, it projects the rows or columns of the sparse matrix onto the columns of a dense matrix.
Suppose A is the large, sparse term-by-document frequency matrix with weighted entries. The SVD of a matrix A is a factorization of A into three new matrices U, D, and V, such thatequation, where matrices U and V have orthonormal columns, and D is a diagonal matrix of singular values. SVD calculates only the first k columns of these matrices (U, D, and V). This is called the truncated decomposition of the original matrix.
After the SVD is computed, each column (or document) in the term-by-document frequency matrix can be projected onto the first k columns of U. Mathematically, this projection forms a k-dimensional subspace that is a best fit to describe the data set. Column projection (document projection) of the term-by-document matrix is a method to represent each document by k distinct concepts.
In other words, the collection of documents is mapped into a k-dimensional space in which one dimension is reserved for each concept. Similarly, each row (or term) in the term-by-document matrix can be projected onto the first k columns of V.
The following description shows the benefits of the SVD. Suppose that you have a document collection as given below. Documents 1, 3, and 6 are about banking at a financial institution. To be more specific, documents 3 and 6 are about borrowing from a financial institution. Documents 2, 4, 5, and 7 are about the bank of a river. Finally, documents 8 and 9 are about a parade. Some of these documents share the same words. A bank can relate to a financial institution or to the shore of a river. “Check” can serve as a noun in document 1 or in an entirely different role as a verb in document 8. “Floats” is used as both a verb in document 4 and as an object that appears in a parade in document 8.
  • Document 1 — deposit the cash and check in the bank
  • Document 2 — the river boat is on the bank
  • Document 3 — borrow based on credit
  • Document 4 — river boat floats up the river
  • Document 5 — boat is by the dock near the bank
  • Document 6 — with credit, I can borrow cash from the bank
  • Document 7 — boat floats by dock near the river bank
  • Document 8 — check the parade route to see the floats
  • Document 9 — along the parade route
Parsing this document collection generates the following term-by-document frequency matrix:
d1
d2
d3
d4
d5
d6
d7
d8
d9
the
2
2
0
1
2
1
1
2
1
cash
1
0
0
0
0
1
0
0
0
check
1
0
0
0
0
0
0
1
0
bank
1
1
0
0
1
1
1
0
0
river
0
1
0
2
0
0
1
0
0
boat
0
1
0
1
1
0
1
0
0
+ be
0
1
0
0
1
0
0
0
0
on
0
1
1
0
0
0
0
0
0
borrow
0
0
1
0
0
1
0
0
0
credit
0
0
1
0
0
1
0
0
0
+ floats
0
0
0
1
0
0
1
1
0
by
0
0
0
0
1
0
1
0
0
dock
0
0
0
0
1
0
1
0
0
near
0
0
0
0
1
0
1
0
0
parade
0
0
0
0
0
0
0
1
1
route
0
0
0
0
0
0
0
1
1
By using the co-occurrence of items from the matrix as a measure of similarity, you can see that documents 1 and 2 are more similar than documents 1 and 3. This is because documents 1 and 2 share the same word bank, but documents 1 and 3 have no words in common. However, in fact, documents 1 and 2 are not related at all, but documents 1 and 3 are similar. The SVD helps overcome this difficulty.
The SVD is then applied to approximate the above matrix, and documents are projected into a reduced dimensional space. The generated SVD dimensions are those that fit the subspace the best in terms of least-square best fit. The following displays show the two-dimensional scatter plot of documents.
scatter plot of documents
Document 1 is closer to document 3 than it is to document 2. This is true even though documents 1 and 3 do not share any of the same words. On the other hand, document 5 is directly related to documents 2, 4, and 7. That is, projections tend to place similar documents—even if they share few common words—close to one another in the reduced space. The SVD represents terms with 2 dimensions rather than the original 16 dimensions (1 dimension for each word).
The following display shows the two-dimensional scatter plot of terms. The terms form four groups:
scatter plot of terms
The following display shows the scatter plot of documents and terms all together:
scatter plot of documents and terms
Last updated: September 15, 2017