Understanding Singular Value Decomposition in the context of LSI - Cross Validated most recent 30 from stats.stackexchange.com 2019-07-21T13:37:02Z https://stats.stackexchange.com/feeds/question/108156 http://www.creativecommons.org/licenses/by-sa/3.0/rdf https://stats.stackexchange.com/q/108156 9 Understanding Singular Value Decomposition in the context of LSI Zhubarb https://stats.stackexchange.com/users/28740 2014-07-16T12:31:53Z 2016-08-07T00:51:03Z <p>My question is generally on Singular Value Decomposition (SVD), and particularly on Latent Semantic Indexing (LSI).</p> <p>Say, I have $A_{word \times document}$ that contains frequencies of 5 words for 7 documents.</p> <pre><code>A = matrix(data=c(2,0,8,6,0,3,1, 1,6,0,1,7,0,1, 5,0,7,4,0,5,6, 7,0,8,5,0,8,5, 0,10,0,0,7,0,0), ncol=7, byrow=TRUE) rownames(A) &lt;- c('doctor','car','nurse','hospital','wheel') </code></pre> <p>I get the matrix factorization for $A$ by using SVD: $A = U \cdot D \cdot V^T$. </p> <pre><code>s = svd(A) D = diag(s$d) # singular value matrix S = diag(s$d^0.5 ) # diag matrix with square roots of singular values. </code></pre> <p>In <a href="http://www.ling.ohio-state.edu/~kbaker/pubs/Singular_Value_Decomposition_Tutorial.pdf" rel="noreferrer">1</a> and <a href="http://files.grouplens.org/papers/webKDD00.pdf" rel="noreferrer">2</a>, it is stated that: </p> <p>$WordSim = U \cdot S$ gives the <strong>word similarity matrix</strong>, where the rows of $WordSim$ represent different words. </p> <p><code>WordSim = s$u %*% S</code></p> <p>$DocSim= S \cdot V^T$gives the <strong>document similarity matrix</strong> where the columns of$DocSim$represent different documents.</p> <p><code>DocSim = S %*% t(s$v)</code></p> <p><strong>Questions:</strong></p> <ol> <li>Algebraically, why are $WordSim$ and $DocSimS$ word/document similarity matrices? Is there an intuitive explanation?</li> <li>Based on the R example given, can we make any intuitive word count / similarity observations by just looking at $WordSim$ and $DocSim$ (without using cosine similarity or correlation coefficient between rows / columns)? </li> </ol> <p><img src="https://i.stack.imgur.com/3KJuT.png" alt="enter image description here"></p> https://stats.stackexchange.com/questions/108156/-/228614#228614 2 Answer by Pieter for Understanding Singular Value Decomposition in the context of LSI Pieter https://stats.stackexchange.com/users/93550 2016-08-07T00:51:03Z 2016-08-07T00:51:03Z <p>Matrix factorization using SVD decomposes the input matrix into three parts:</p> <ul> <li>The left singular vectors $U$. The first column of this matrix specifies on which axis the rows of the input matrix vary the most. In your case, the first column tells you which words vary together the most. </li> <li>The singular values $D$. These are scalings. These are relative to each other. If the first value of $D$ is twice as big as the second it means that the first singular vector (in $U$ and $V^T$) explain twice as much variation as the seconds singular vector.</li> <li>The right singular vectors $V^T$. The first row of this matrix specifies on which axis the columns of the input matrix vary the most. In your case, the first row tells you which documents vary together the most. </li> </ul> <p>When words or documents <em>vary together</em> it indicates that they are similar. For example, if the word doctor occurs more often in a document, the word nurse and hospital also occur more. This is shown by the first scaled left singular vector, the first column of $WordSim$.You can validate this result by looking at the input data. Notice that when nurse does occur, hospital also occurs and when it does not occur, hospital also does not occur. </p>